【Codex调优】Codex 默认压缩 Prompt 到底有多坑?缓解 5.6 sol 上下文本地压缩幻觉问题

lanvent 2026-07-31 23:34 1

因为不少公益站不支持远程压缩,只能依赖本地压缩。然而,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.

实测它在压缩后经常触发以下问题:



  1. 新旧需求混淆。中途对话修改了需求,结果废弃方案又被端了上来和最终方案搅在一起。LLM反复检查旧任务。

  2. 把提议当决策,产生幻觉。Agent之前的提议“要不要试试 A 方案?”被直接记成“用户采用 A 方案”,导致压缩后跑偏。

  3. 过早抽象,丢失重要细节。因为原始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"
最新回复 (15)
  • 文月 07-31 23:38
    1

    我也发现了压缩丢上下文的问题,感觉压缩后只记得我的提示词了,然后会把已经完成过的步骤重复执行


    试试这个

  • topherowhale 07-31 23:44
    2

    好的佬,已经改完了,最近sol一直跑大型项目,自动压缩完我就没细看,如果是这样的话,我得好好检查一下了

  • Decidable6471 07-31 23:45
    3

    关键是 到底远程压缩没有也不知道啊

    我看我 上下文 0 缓存 打出去了

    但是压缩后就流口水

  • Angel 07-31 23:47
    4

    到底远程压缩没有也不知道啊



    中转站的话 看一下 有没有这个模型

    gpt-5.6-sol-openai-compact这种接口

    没有的话是大概率不行的^-^^-^^-^^-^

  • Decidable6471 07-31 23:48
    5

    不是吧 不是说现在不需要这个模型吗?

    我有点搞不懂了 说远程压缩 V2 很牛

    反正就是 0 缓存打出去

  • lanvent 楼主 07-31 23:48
    6

    config.tomlmodel_providers中的name不是OpenAI,就是本地压缩。


    如果填的是OpenAI,但远端不支持远程压缩,那么它会直接报错。

  • Decidable6471 07-31 23:49
    7

    那就是远程压缩了啊

    对吧

    设置的 OpenAI

    然后打到中转站 这个时候会 0 缓存

    然后开始流口水

  • jwdszye 07-31 23:50
    8

    5.6的远程压缩不是合并回response端点了吗,不需要/compact了



    加入下面这条设置



    佬友请问下,在Configuration Reference | ChatGPT Learn 中我看到还有一个compact_prompt配置可以不使用外挂文件,直接填写文字,这个效果应该是一样的吧

  • Angel 07-31 23:57
    9

    5.6的远程压缩不是合并回response端点了吗



    那要么就是我的配置有问题 我的只能实现本地压缩^-^^-^^-^

  • qsyao 07-31 23:57
    10

    太强了,佬,那是不是可以使用mattpocockhandoffskill效果是不是更好

  • jwdszye 07-31 23:58
    11

    可能现在中转站也是没有更新适配这种v2压缩的

  • lanvent 楼主 08-01 00:01
    12

    是的,这两个的效果是一样的,不过会让config.toml有一丢丢膨胀 ^-^

  • lanvent 楼主 08-01 10:43
    13

    我看了下不太适合,handoff主要用于跨对话交接

  • k8sgogo 08-01 19:04
    14

    感谢分享! 把佬的 prompt 让 Fable review 了一下 (在 codex repo 中运行 CC, 让它结合源代码分析),它的主要意见是。there is no target length or required output structure. 可能会导致输出很长。


    Fable 修改 → codex review → Fable 再修改之后的版本:


    Create a faithful context-compaction summary of the conversation above for a model that will resume the task with this summary in place of the discarded context.

    Treat the summary as the only reliable surviving record of the discarded context. Assistant messages, reasoning, tool calls, and tool results are never carried forward, so the summary is the sole carrier of assistant-side work: restate in text anything that still matters but appeared only in tool output, images, or attachments. If the conversation already contains an earlier checkpoint summary, carry its still-relevant content forward too. Workspace artifacts — files, branches, commits — persist: prefer referencing them by exact path or command over inlining content the resuming model can re-read, unless the conversation established an interpretation of that content that the artifact alone would not convey. Live state — running processes, terminals, tool sessions, pending external jobs — may not survive: record its identity, purpose, last observed status, and how to check on or restart it, without assuming it is still available.

    Preserve all material information needed to understand the task and its current state: objectives, requirements, constraints, corrections, decisions and their rationale, work completed and in progress (including any step interrupted by this compaction), unfinished work, relevant evidence, failures, uncertainties, active external or background work, and surviving artifacts or references. Do not omit material information merely because it occurred early or in the middle of the conversation.

    Keep the status of every important claim distinct and accurate. Reconcile earlier information with later evidence and corrections, keeping current, superseded, rejected, tentative, failed, and unresolved information clearly separated. Preserve provenance: distinguish user instructions from assistant proposals, quoted or relayed material, direct observations, inferences, and verified results. Never promote a proposal, intention, prediction, or suggested next step into an accepted decision, governing requirement, or verified state: record what was proposed, whether it was accepted, rejected, superseded, or left unanswered, and what work actually started or finished. Do not present a next action as required unless the governing instructions and conversation state support that status.

    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.

    Organize the summary so status is visible at a glance — for example by separating governing instructions, established facts, completed work, work in progress, open questions, and possible (not committed) next steps — adapting the grouping to the conversation rather than forcing empty sections. Avoid repetition, routine narration, raw logs, and detail reconstructible from durable artifacts without loss of interpretation. Use as much detail as fidelity requires, and no more: the summary must be materially smaller than the context it replaces, or it has failed as a compaction.
  • lanvent 楼主 08-01 20:04
    15

    谢谢佬的回复,在调优时我也尝试过限制长度,不过因为5.6倾向极致省Token,施加限制有时会让结果过于精简。无长度限制版本我在3个几百到一千轮的超长开发Session里测试过,靠它自身提炼反而效果还不错,输出稳定在8000 tokens内,不超过1%上下文窗口。

* 帖子来源Linux.do
返回