Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

principle-guard-the-context-window

守住 context window

The context window is finite and non-renewable within a session. Every token should be worth its cost.

context window 在会话内有限且不可再生。每个 token 都要值回代价。

Why: Context overflow degrades reasoning quality, creates compression artifacts, and halts progress.

为什么: context 溢出会拉低推理质量、产生压缩伪影,并卡住进度。

Pattern:

模式:

  • Isolate large payloads. Route verbose outputs, screenshots, and large documents to subagents. The main context gets summaries, not raw data.

  • Don’t read what you won’t use. Read selectively based on relevance. If a file isn’t needed for the current task, skip it.

  • Keep frequently used content inline. Templates and references used on every invocation belong in the skill file, not in separate files that cost a read each time.

  • Size phases and cap scope. Limit files per phase, set turn budgets, account for mechanism costs.

  • 隔离大载荷。 冗长输出、截图、大文档交给 subagent。主 context 只要摘要,不要原始数据。

  • 不用的别读。 按相关性选择性读。当前任务不需要的文件就跳过。

  • 常用内容内联。 每次调用都用的模板和参考放进 skill 文件,别放在每次都要读一遍的单独文件。

  • 给阶段定尺、给范围设顶。 限制每阶段文件数,设回合预算,计入机制成本。