Repository navigation
fix(context): retain output-budget guidance after context loss - #7594
Conversation
|
This pull request has merge conflicts with Choose the remote for the base repository, not an out-of-date fork. git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEADFor a same-repository clone whose Keep the DCO |
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
75194f4 to
098f4d4
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent; model=gpt-6.1-sol; provider=OpenAI; reasoning_effort=max; declaration_source=runtime_reported.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
APPROVE — 完整评审当前 head 098f4d4,未发现阻塞问题。这个结论限定于恢复指引修复;实际宿主与模型表现仍有下述未验证边界。
动机 / Motivation
压缩后继续读取原始上下文的 Codex Agent。配置阶段说明了内层读取和外层输出预算,恢复 hook 却没有携带这两项提示;当配置文字已经丢失,Agent 会失去同一读取路径所需的调用信息。
恢复 hook 独立携带既有预算提示,原 capture、读取顺序、缺失内容恢复和原 Turn 身份继续保留。本 PR 完成既有 native 恢复指引的有界修复;不改变宿主配置、准入、上下文裁剪、journal 或结算。 原生宿主实际遵循提示、模型保留、完整成本和长程净收益未验证。
改动思路 / Approach
同一 native Host 适配器的两个实际文本消费者共享一段 111 字节提示;没有新决策 owner、配置或持久状态。本 PR 完成既有 native 恢复指引的有界修复;不改变宿主配置、准入、上下文裁剪、journal 或结算。
我先比较了不改、在 hook 直接复制 setup 文字、以及复用现有片段三种方案。前者保留了可复现的缺口,复制会让两个入口继续漂移;当前实现让已有配置与恢复消费者使用同一文字,同时不移动 TypeScript lifecycle 决策。最重要的反例是:提示变短或预算增加,是否会被误当作完整读取、保留输入或重新准入的证明。实际比较确认原 continuation 和分页指引逐字保留,设置值、hooks、命令、身份选择及错误恢复均未更改。这样一次修复就能从真实恢复入口被消费,不需要先完成更大的上下文重构。
具体改动 / Changes
全 PR 为四个文件 +34/-4,一个带 DCO 的提交:生产适配器 +10/-2,原指南的中英文段落 +12/-1,两个既有测试文件 +12/-1。没有新状态、协议、CLI 或生成文件。
判断依据是修改前已接受的 docs/reference/required-work-context.md,spec_revision 为 0d4bf99。以下标签映射原文中未编号的要求:
| criterion_id | 本 head 的处置 |
|---|---|
| same-turn-original-identity | implemented:压缩只使 delta 基线失效,原工作 Turn、任务和结算身份保留;原 continuation 块逐字相同。 |
| complete-same-capture-read | implemented:未完成的必读内容仍须从原 capture 补读;完整覆盖、缺段重读及禁止重复 effects 的规则不变。 |
| native-output-activation-boundary | implemented:复用现有内层 22000 / 外层 24000 请求提示,实际限制仍由宿主决定;不更改 64000-byte profile 或 20000-token 配置。 |
关键代码讲解
- _NATIVE_CONTEXT_OUTPUT_GUIDANCE 只承载 111 字节、以 64000-byte pages 为条件的两层预算提示。它不是大小放宽、读取完成回执或授权。
- codex_context_recovery_instructions 在原配置路径复用片段;每次直接转发 stdout、按历史限制选批量以及截断后补读的含义保留。
- codex_context_hook 只在 SessionStart、当前会话确需恢复且持有原引用时加入提示;关闭、外国会话和普通工具输出仍走原路径。两个既有测试文件扩展同一恢复 oracle,没有删除断言或提高 2300 的回归上限。
对主干的风险 / Risks
最强风险是把缺失输入的恢复提示变成新的准入、读取完成或宿主配置证明。对此,原 Task/capture/settlement、必要事实补读、完整初读、独立合法工作和不得重复结算等句子逐字比较相同;原 paging 块也完全相同。实际 CLI 在 FIFO 历史和关闭状态下的分支均覆盖,未借成功输出推断模型保留。
| 独立验证 | 结果 |
|---|---|
| 同一冻结的 12 项恢复 oracle | base:10 项缺少预算提示而 FAIL、2 项关闭路径 PASS;head:12 PASS |
| 当前源码相关测试 | 246 PASS;75 项需显式 native binary 的选择性用例 SKIPPED,未计入通过 |
| 三种现有 native configuration 对照 | 非指引字段完全一致;setup 指引各增加 26 UTF-8 bytes,原 continuation/paging 逐字相同 |
| 当前风险 premerge | 6 direct + 11 selected PASS,零失败、零 manual hold |
| 新 wheel 的隔离真实路径 | 12 PASS;其中 5 次 CLI 子进程及父进程来自 site-packages,关键生产文件与当前 git head 逐字相同 |
初次 wheel 构建明确拒绝了过期的 Chat 资源;按现有 build:chat 流程重建忽略资源后,新构建及安装验证通过,受版本控制源码保持干净。私有探针初次使用了不存在的目录,拒绝被保留,修正的是测试输入。未降低预算、去掉原断言或将 skip 当作通过。未查询或等待 CI。
语义与 CI 对齐
这是既有 native Host adapter 的局部指引复用,没有新共享词表,也没有 Python 第二决策 owner。默认关闭隔离用例保留空输出与 journal 不变;文档清楚区分预算请求、完整字节交付、实际保留和执行权限。premerge 与受影响真实路径已验证,原生宿主遵从度则未冒充完成。
我的整体评价 / Verdict
这个已复现的指引缺口已在当前 head 关闭,范围与代价相称。long_horizon 和 user_experience 的局部改善是恢复入口能独立提供正确提示,不要求用户增加确认或重新输入。它不等于模型已采用、长期成本下降或整个上下文工作已完成。共享片段是本次适当的简化;没有必要加入新的生命周期框架。
已检查 loopx/control_plane/turn_driver/codex_context.py 的生成指引与实际 CLI 路径;没有可视页面改动。
未宣称 UI 交付。原生宿主实际遵循提示、模型保留、完整成本和长程净收益未验证。
原生宿主实际遵循提示、模型保留、完整成本和长程净收益未验证。没有可视页面改动,截图不适用。批准不替代实际 merge-readiness 或维护者的合并决定。
English verdict: APPROVE 098f4d4. The missing recovery-budget hint is fixed; baseline/head recovery and exact-wheel checks pass. Native-host/model compliance and total-cost benefit remain unverified.
|
Maintainer-authorized merge after the published exact-head review, focused source and isolated-wheel checks, risk-based premerge, bilingual validation, and an immediately preceding ready merge-readiness result. Admin bypass is limited to the configured no-CI-wait delivery policy; CI was not queried and is not represented as passed. Native-host adoption, total model cost and long-horizon benefit remain unqualified. |
After context loss, the native recovery hook supplies a capture-read command without the inner-reader and outer code-mode output budgets already present in setup. The existing #7594 proposal now integrates #7600/#7601/#7606 and shares a minimal host-owned budget fragment between setup and recovery.
For the existing 64,000-byte profile, it requests the same 22,000 reader / 24,000 code-mode output tokens. Requests are bounded by the actual host; truncation still requires smaller pages from the same capture. This changes instruction delivery, with no host configuration, production page limits, source selection, admission, journal or settlement change.
Current head
098f4d49d6c552214515289dd7dd50ed40e6a17ais rebased onto main0d4bf99a4aa6080f2774f3c4477fb4adc1b5ac46. The old 75194f4 text was refined rather than mechanically appended: current Turn continuity and paging clauses remain byte-identical, including no new admission for compaction, no replay of completed reads/effects, and recovery of missing necessary facts from the original capture. Setup still requires direct successful stdout forwarding and preserves its per-call rule. One Python native-adapter fragment serves the two existing IO callers; no new decision owner or capability is introduced.Validation on this head:
The old 75194f4 qualification remains historical: 203 passes and separate 20 passes / 24 optional skips on its earlier source. Its 2,000 → 2,300 test-ceiling change and old text measurements do not describe this new-base patch; the current base already has 2,300 and this proposal does not raise it.
No CI query, poll or wait, active installation, paid model call or benchmark launch was performed. Native-host/model compliance, fewer compactions, complete-context size and total outcome/cost benefit remain unqualified. English and Chinese reference guidance are updated together.