针对DSH:添加第三方中转站模型时上下文长度被默认256K问题(DeepSeek Harness小完善计划其一)
August 20, 2026 · View on GitHub
DSH: Third-Party Relay Models Default to 256K Context Window (DeepSeek Harness Improvement Plan, Part 1)
DSH(DeepSeek Harness)第三方模型上下文窗口配置技能(Agent Skills 标准格式)。
An Agent Skill (standard Agent Skills format) for configuring the real context window of third-party models connected to DeepSeek Harness (DSH).
中文文档
技能标识:
01-context-window| 系列:DeepSeek Harness 小完善计划(其二:思考强度调节 · 其三:视觉能力解禁)
这是什么
一个符合 Agent Skills 标准(SKILL.md + YAML frontmatter + references/ 渐进披露)的独立技能仓库。它告诉 AI:当 DSH 中手工接入的第三方模型只显示默认 256K 上下文时,如何定位 settings.yaml、查证模型真实窗口并写入 contextWindow。
项目目的
DSH 0.1.0-rc.7 手工接入第三方模型(官方直连或中转站路由)时存在一个缺陷:pi-ai 内置目录查不到这些手工路由的条目,模型配置不写 contextWindow 就回退到默认 256K(262144),与模型真实窗口(1M / 500K 等)不符,导致压缩(compaction)时机错误——窗口被低估时压缩来得太早,被高估时长对话会触发上游 CONTEXT_WINDOW_EXCEEDED。
本仓库是一个 Agent Skill:给 AI 看的"维修手册",不是可执行软件。AI 读完 SKILL.md,就能按规程自行定位 settings.yaml、查证模型真实窗口并写入正确的 contextWindow,完成修复。
症状速查
出现以下现象时,本技能适用:
- DSH 会话统计行的上下文只显示 256K(
262144),而模型官方标称 1M / 500K; - 手工路由 / 中转站接入的模型窗口不对,压缩(compaction)来得太早;
- 长对话时上游报
CONTEXT_WINDOW_EXCEEDED(窗口填高了,或与路由默认值打架)。
关键词:DSH contextWindow 只有 256K、settings.yaml、手工路由、中转站、压缩过早。
仓库结构
01-context-window/
├── SKILL.md # 技能入口(AI 读这个)
├── README.md # 仓库说明(人读这个)
├── AGENTS.md # 维护守则(给维护本仓库的 AI 看)
└── references/
├── deep-dive.md # 原理、源码定位、跨平台安装路径、排障表
└── examples.yaml # 完整配置示例(修改前/后、多路由)
使用方法
- 安装:把本目录整体放入你所用 AI 的 skills 目录(各 AI 的技能目录位置不同,按其文档放置即可)。
- 触发:直接向 AI 描述症状,例如"DSH 里这个模型上下文只显示 256K"。AI 命中本技能后会加载
SKILL.md执行。 - AI 会做什么:
- 定位
settings.yaml(跨平台路径见SKILL.md第 1 步); - 逐型号查证真实窗口(先查本机 pi-ai 内置目录,再查官方文档);
- 在对应模型条目写入
contextWindow并保存(立即生效,无需重启); - 提示你验证:新会话统计行的窗口数值是否刷新为新配置。
- 定位
- 用户要配合什么:
- 审批提升权限:
settings.yaml在会话工作区之外,AI 写入需提升权限并经你审批; - 避免并发改写:DSH 界面开着时配置可能被界面实时重写,修复期间尽量不要在界面里改供应商设置;
- 改完自行备份:通过界面修改供应商会重写整个配置段,手工加的字段会被静默抹掉;
- 数值不要瞎填:让 AI 逐型号查证后再写,高估窗口会导致长对话时上游报
CONTEXT_WINDOW_EXCEEDED。
- 审批提升权限:
版本基线
内容基于 DSH 0.1.0-rc.7 + @earendil-works/pi-ai 0.82.1(2026-08 实战验证)。DSH 升级后字段名可能变化,请按 references/deep-dive.md 的源码定位入口重新核实并更新 frontmatter 的 metadata.baseline。
许可
本文档以 CC BY 4.0 协议发布(署名 4.0 国际)。引用、转载、二次创作请保留署名:xiaohui5206。
English
Skill ID:
01-context-window| Series: DeepSeek Harness Improvement Plan – Part 2: Reasoning Effort · Part 3: Vision Input
What This Is
A standalone skill repository following the Agent Skills standard (SKILL.md + YAML frontmatter + progressive disclosure under references/). It tells the AI what to do when a hand-connected third-party model in DSH shows only the default 256K context: how to locate settings.yaml, verify the model's real context window, and write the correct contextWindow.
Project Purpose
Hand-connecting a third-party model in DSH 0.1.0-rc.7 (direct official API or via a relay gateway) has a flaw: the pi-ai built-in catalog has no entry for these hand-declared routes, so a model entry without contextWindow falls back to the default 256K (262144). That mismatches the model's real window (1M / 500K, etc.) and breaks compaction timing — underestimate it and compaction kicks in too early; overestimate it and long conversations trigger an upstream CONTEXT_WINDOW_EXCEEDED.
This repository is an Agent Skill: a "repair manual" written for the AI, not executable software. After reading SKILL.md, the AI can follow the procedure on its own — locate settings.yaml, verify the model's real context window, and write the correct contextWindow to complete the fix.
Symptom Checklist
This skill applies when you see any of the following:
- The DSH session stats line shows only 256K (
262144) of context, while the model is officially rated at 1M / 500K; - A model connected via a hand-declared route / relay gateway gets the wrong window, and compaction kicks in far too early;
- Long conversations hit an upstream
CONTEXT_WINDOW_EXCEEDED(the window was set too high, or it conflicts with the route-level default).
Keywords: DSH contextWindow stuck at 256K, settings.yaml, hand-declared route, relay gateway, premature compaction.
Repository Structure
01-context-window/
├── SKILL.md # Skill entry point (the AI reads this)
├── README.md # Repo overview (for humans)
├── AGENTS.md # Maintenance rules (for AIs maintaining this repo)
└── references/
├── deep-dive.md # Rationale, source-code anchors, cross-platform install paths, troubleshooting
└── examples.yaml # Full config examples (before/after, multi-route)
How to Use
- Install: Drop this entire directory into your AI's skills directory (the location varies by AI — follow its documentation).
- Trigger: Just describe the symptom, e.g. "this model only shows a 256K context window in DSH". The AI will match this skill and load
SKILL.mdto run it. - What the AI does:
- Locates
settings.yaml(cross-platform paths in step 1 ofSKILL.md); - Verifies the real context window model by model (local pi-ai built-in catalog first, then official docs);
- Writes
contextWindowinto the matching model entry and saves (takes effect immediately, no restart needed); - Asks you to verify: does the session stats line refresh to the new window value?
- Locates
- What you need to do:
- Approve the elevation:
settings.yamllives outside the session workspace, so the AI needs elevated write permission with your approval; - Avoid concurrent edits: while the DSH UI is open it may rewrite the config in real time — avoid changing provider settings in the UI during the fix;
- Back up after changes: editing providers through the UI rewrites the whole section and silently wipes hand-added fields;
- Don't guess the number: let the AI verify the value model by model first — setting it too high causes an upstream
CONTEXT_WINDOW_EXCEEDEDin long conversations.
- Approve the elevation:
Version Baseline
Content is based on DSH 0.1.0-rc.7 + @earendil-works/pi-ai 0.82.1 (field-verified 2026-08). Field names may change after DSH upgrades — re-verify against the source-code anchors in references/deep-dive.md and update metadata.baseline in the frontmatter.
License
This document is released under CC BY 4.0 (Attribution 4.0 International). When quoting, reposting, or remixing, please keep the attribution: xiaohui5206.