因为不少公益站不支持远程压缩,只能依赖本地压缩。然而,Codex 自带的默认压缩 Prompt 是这样的:
You are performing a CONTEXT CHECKPOINT COMPACTION. Create a handoff summary for another LLM that will resume the task.
Include:
- Current progress and key decisions made
- Important context, constraints, or user preferences
- What remains to be done (clear next steps)
- Any critical data, examples, or references needed to continue
Be concise, structured, and focused on helping the next LLM seamlessly continue the work.
实测它在压缩后经常触发以下问题:
- 新旧需求混淆。中途对话修改了需求,结果废弃方案又被端了上来和最终方案搅在一起。LLM反复检查旧任务。
- 把提议当决策,产生幻觉。Agent之前的提议“要不要试试 A 方案?”被直接记成“用户采用 A 方案”,导致压缩后跑偏。
- 过早抽象,丢失重要细节。因为原始prompt强调
Be concise,比如会把具体API路径 /api/v1/user 抽象成“用户接口”。
这些问题在从5.5切换到5.6 sol后更盛,因为sol偏向于提高token效率,concise的问题被放大。
除了换成支持远程压缩的渠道外,一种解决方案是通过类似trellis这些harness来解决,但是该类方案会增加较多的token开销,增长工作路径,这在中小项目里没有必要。
个人的解决方案是使用自定义的compact指令。让sol消耗大量token调出了以下prompt,实测能够有效缓解上述问题。
Create a faithful context-compaction summary of the conversation for a model that will receive the summary instead of the discarded context.
Preserve all material information needed to understand the user's task and its current state, including objectives, requirements, constraints, corrections, decisions and their rationale, work completed or in progress, unfinished work, relevant evidence, failures, uncertainties, active external work, and surviving artifacts or references.
Reconcile earlier information with later evidence and corrections. Keep current, superseded, rejected, tentative, failed, and unresolved information distinct. Preserve the source and status of important claims, especially the distinction between user instructions, assistant proposals, quoted or relayed material, direct observations, inferences, and verified results.
Do not turn a proposal, intention, prediction, or suggested next step into an accepted decision, governing requirement, or verified current state. Preserve separately what was proposed, whether it was accepted, rejected, superseded, or left unanswered, and what work was actually started or completed. Do not label a next action as required unless that status is supported by the governing instructions and conversation state.
Preserve exact names, identifiers, paths, versions, values, counts, relationships, and state transitions when they materially affect understanding or future work. Do not invent facts, completion, decisions, authorization, verification, or certainty. Do not omit material information merely because it occurred early or in the middle of the conversation.
Avoid repetition, routine narration, raw logs, and detail that can be safely reconstructed without changing the interpretation of the task. Use as much detail as necessary for fidelity; there is no target length or required output structure.
generic-faithful-v2.md.txt (1.8 KB)
使用方法:下载后,在~/.codex/config.toml顶部加入下面这条设置,修改成相应路径,重开对话即可。
experimental_compact_prompt_file = "<path>/generic-faithful-v2.md.txt"