S6-07 · 进阶 S6-07 · Advanced

上下文工程 · 窗口里该放什么 Context Engineering · Decide What Goes In

select + organize + compress + update → useful context under a token budget

上下文工程(Context Engineering)是在模型不改权重的前提下,系统化选择、组织、压缩和更新当前推理可见的信息。S3 解释窗口容量是什么;本页解释有限容量里放什么。 Context engineering systematically selects, organizes, compresses, and updates what the model can see without changing weights. S3 defines window capacity; this lesson decides what earns space inside it.

01 · 行李箱装得下,不代表装得对 01 · Fitting is not packing well

只有 10 格预算时,你会带规则、旧聊天、关键证据,还是刚返回的工具结果? With ten budget slots, do you pack rules, old chat, decisive evidence, or the latest tool result?

02 上下文预算箱:逐件取舍 Context Budget Box: Choose Item by Item

选材,不改窗口结构 curation, not capacity
预算占用 Budget used
10/10
tokens
问题覆盖 Coverage
100%
规则 + 事实 + 现状 rule + fact + current state
冲突 Conflicts
0
clean context

03 四类材料,四种职责 Four Material Types, Four Jobs

选择 · 组织 · 更新 select · organize · update
RULE

规则定边界 Rules set boundaries

保留当前有效的业务约束,过期版本必须移除或明确标记。 Keep the current business constraint; remove or clearly mark superseded versions.

HISTORY

历史保连续 History preserves continuity

只留当前任务需要的决定与指代,不把整段聊天无差别塞回去。 Keep decisions and references needed now, not the entire conversation indiscriminately.

EVIDENCE

证据回答事实 Evidence answers facts

证据要相关、可追溯,并与问题中的关键判断直接对应。 Evidence should be relevant, traceable, and tied directly to the decision in question.

TOOL

工具结果给现状 Tools provide current state

把刚执行后的真实返回送回上下文,避免用旧猜测代替环境状态。 Feed back the actual result of an action instead of substituting an old guess for current state.

04 最小机制:价值必须覆盖成本与冲突 Minimal Mechanism: Value Must Beat Cost and Conflict

Σ tokens ≤ B
useful = coverage − conflict − overflow
B = 10。勾选材料会同时改变覆盖、冲突和超预算,不能只追求“塞得多”。 B = 10. Each selection changes coverage, conflict, and overflow; maximizing volume is not the objective.
选择必要材料 Select necessary material 规则、证据、现状 rule, evidence, current state
检查预算与冲突 Check budget and conflict 旧摘要可能过期 old summary may be stale
压缩或移除 Compress or remove 让每个 token 有职责 make every token earn its place

05 边界实验:什么都舍不得删 Boundary Test: Refuse to Remove Anything

主动制造失败 Create a failure

把过期历史也塞进预算箱 Pack stale history as well

全选后占用 14/10,旧摘要还与最新规则冲突。装得更多,覆盖没有增加,反而制造超限与版本冲突。 Selecting everything uses 14/10, while the old summary conflicts with current policy. More material adds overflow and version conflict without more coverage.

尚未执行。推荐组合正好占满 10 格。 Not run yet. The recommended set fills exactly ten slots.
上下文工程就是把提示写长。 Context engineering means writing a longer prompt. → ✓ 它还负责选择、组织、压缩和更新材料。 It also selects, organizes, compresses, and updates material.
窗口放得下,就应全部放进去。 If the window fits it, include everything. → ✓ 容量是 S3 的上限;选材质量是 S6 的任务。 Capacity is the S3 limit; curation quality is the S6 job.
旧历史总能帮助保持连续。 Old history always improves continuity. → ✓ 过期摘要可能与当前规则直接冲突。 A stale summary may directly conflict with current policy.
06 · 一句话带走 06 · One line to keep

上下文工程不是扩大窗口,而是在固定预算内选择、组织、压缩和更新规则、历史、证据与工具结果,使覆盖增加而冲突和浪费减少。 Context engineering does not enlarge the window; it selects, organizes, compresses, and updates rules, history, evidence, and tool results so coverage rises while conflict and waste fall.