principle-guard-the-context-window

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Guard the Context Window

守护上下文窗口

The context window is finite and non-renewable within a session. Every token that enters should earn its place.
Why: Context overflow degrades reasoning quality, creates compression artifacts, and halts progress. Unlike compute or time, context spent inside a session cannot be reclaimed.
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.
会话中的上下文窗口是有限且不可再生的。每一个进入窗口的token都必须有其存在的价值。
原因: 上下文溢出会降低推理质量,产生压缩失真,并阻碍任务推进。与计算资源或时间不同,会话中消耗的上下文无法回收。
模式:
  • 隔离大负载内容:将冗长的输出内容、截图和大型文档路由至子Agent。主线程仅保留摘要,而非原始数据。
  • 不读取无用内容:根据相关性选择性读取。如果某个文件当前任务不需要,就跳过它。
  • 常用内容内嵌保存:每次调用都会用到的模板和参考内容应放在skill文件中,而非每次读取都要消耗资源的单独文件里。
  • 分阶段控制规模与范围:限制每个阶段的文件数量,设置轮次预算,考虑机制成本。