Skip to content

feat(agent): add native ChatGPT compaction checkpoints - #6584

Merged
M4n5ter merged 2 commits into
feat/codex-state-provenancefrom
feat/codex-native-compaction
Nov 3, 2026
Merged

M4n5ter merged 2 commits into
feat/codex-state-provenancefrom
feat/codex-native-compaction

Conversation

@me2seeks

@me2seeks me2seeks commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

ChatGPT subscription /compact now uses native encrypted compaction instead of an ordinary text-summary request. The subscription provider declares support, Host freezes one ModelOperation, and the Responses adapter appends compaction_trigger through its shared HTTP/WebSocket request body. The trigger is not an assistant message or durable history part. The adapter returns validated, typed NativeCompaction only after stream completion; Engine and EventLog no longer extract the result from provider_options.openai.compaction.

Native checkpoint headers retain the producing-step reference, item digest, token estimate and existing coverage proof. Producer/model facts are derived from the original request when reading the baseline rather than stored and compared twice. The original completed event owns the opaque payload once. Same-model replay, re-compaction, continuation and replay after restart preserve the item and required suffix. Incomplete, invalid or cancelled native output leaves original history recoverable, with no ChatGPT text-summary fallback. Declaring native capability without ChatGPT producer facts fails before dispatch.

Session/global/custom prompt editors, Host queries and prompt-bearing API calls remain available. Saved text prompts continue serving other providers and are not sent as ChatGPT summary instructions. No legacy decoder/migration is added.

Refs #6579. Stack layer 2/4, based on #6580. This layer permits native replay for the producing model. Unified cross-model admission is PR3; switch/window preflight is PR4. Existing in-flight Summary recovery policy is not expanded.

Base review follow-up

The latest maintainer review found no new blocking issue in this layer and reran 111 facts/model tests, seven native/background integration cases and 15 EventLog compaction cases successfully. This revision rebases onto #6580's admitted-settings correction and its updated Workhub/inventory fixtures. The stack additionally verifies that a display-name/default edit does not interrupt an accepted message, while actual route/disable checks remain enforced. CI still needs to complete on the new stack heads.

Verification

  • Six native engine integration tests pass: compact/replay/re-compact/restart, invalid text-only output, cancellation before completion, continuation after a native prefix, same-model hash-change re-compaction without new messages, and missing subscription facts.
  • The existing background scenario now runs for text and native compaction. Both requests overlap before either receives a response; steering/tool suffixes survive adoption once and in order; a physical retry sends the original frozen request even after compaction completes.
  • Model library: 48 passed, including native decoder and HTTP/WebSocket wire parity. Facts library: 63 passed. Event-log compaction/proof: 15 passed. Existing text history, automatic compaction (6), handoff, pruning and frozen-request tests pass.
  • Host test compilation; scoped Host/engine/model/event-log/facts Clippy with -D warnings; formatting and git diff --check pass.
  • Initial concurrent engine checks during compilation timed out. Serial reruns of the affected background/handoff/pruning groups passed, and the central background test also passed alone.
  • Earlier live synthetic-content subscription probing (gpt-6-luna, HTTP) verified native compaction, marker recall from opaque state, checkpoint-only replay and re-compaction. The current refactor is validated locally; a fresh live probe and live WebSocket service probe were not run.
  • Full repository just check was not run; The latest hosted run passed build, Clippy, packaging and Desktop checks, but failed two Goal tests whose expectations conflicted with this PR’s frozen admitted-settings behavior. Those tests now verify that existing Goal grants retain approved defaults, newly admitted messages use edited defaults, and a real endpoint replacement still pauses until reapproval. All 11 Goal tests pass locally; hosted CI must rerun on the updated stack.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex implementation and tests; independent GPT-6.1 Terra medium read-only review. Its missing-context finding was fixed and tested; subsequent review found no concrete remaining issue. AI review does not replace human review.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@me2seeks
me2seeks added this pull request to stack #6585 November 2, 2026 16:42
@me2seeks
me2seeks marked this pull request as ready for review November 2, 2026 20:05

@M4n5ter M4n5ter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English

The stack-wide feedback is in the review on #6579. For this PR, the relevant points are 2, 3 and 6:

  1. Consolidate the operation and keep provider protocol details at their boundary. Native compaction currently spans ModelOperation, ProviderOperation, AssistantPart::CodexCompactionTrigger, and the recipe/overlay/serialization/measurement paths. Results are placed in provider_options.openai.compaction and interpreted again by the engine and EventLog. Please retain the business-purpose distinction between Main and Summary, but consolidate the protocol operation and let the selected adapter encode the trigger and return a clearly typed native result. Provider declares capabilities, Host freezes the prepared facts, and the engine owns the common lifecycle. This should remove cross-layer special cases through the existing interfaces, not introduce a new services framework.

  2. Derive checkpoint producer/model facts from the producing request. summary_step_id already references that request, and context/proof.rs reads it before comparing the checkpoint's copied producer/model fields with the original facts. Keep the producing-step reference, content digest and coverage proof; expose producer/model as a derived baseline projection rather than another persistent copy.

  3. Close the native background-concurrency coverage gap. The existing text-background test covers Main progressing while compaction runs, a fixed source cutoff, new messages/tool suffixes, and physical retries of a frozen request. Preserve it and reuse the scenario for native compaction: both requests should genuinely overlap, adoption must retain the suffix exactly once, and physical retries must retain their original request semantics. Persistence, cancellation and same-model replay tests alone do not establish that concurrency behavior. This is a coverage gap, not a claim that a native async regression has been reproduced.

Please address points 2 and 3 before merging and add the focused behavioral validation in point 6. Keep the existing capture → background execution → safe adoption structure and the independent request path for compaction. Ordinary proactive compaction should continue to overlap Main; model-switch preconditions and actual capacity exhaustion have their own reasons to wait.

简体中文

整组改动的意见见 #6579 总评。这条 PR 对应总评的 第 2、3、6 项:

  1. 收敛操作表达,把提供商协议细节留在对应边界。 原生压缩目前贯穿 ModelOperation、ProviderOperation、AssistantPart::CodexCompactionTrigger,以及 recipe、overlay、序列化和计量路径。结果先放进 provider_options.openai.compaction,再由执行引擎和 EventLog 重新解释。请保留 Main/Summary 的业务用途区别,但收敛协议操作,让选中的适配器编码触发命令、返回明确类型的原生结果。Provider 声明能力,Host 冻结准备好的事实,执行引擎负责通用生命周期。应通过现有接口减少跨层特例,无需新增一套特殊服务框架。

  2. 从来源请求派生检查点的 producer/model。 summary_step_id 已经引用来源请求,context/proof.rs 也会先读取该请求,再比较检查点复制的 producer/model 与原事实是否一致。请保留来源步骤引用、内容摘要和覆盖证明,将 producer/model 作为派生的 baseline 投影,而非另一份持久副本。

  3. 补齐原生后台并发的验证。 现有文本后台压缩测试覆盖了压缩期间 Main 继续推进、固定源截止点、新消息和工具后缀,以及冻结请求的物理重试。请保留并复用这条场景验证原生压缩:两个请求真正重叠,采用结果后后缀恰好保留一次,物理重试保持原请求语义。持久化、取消和同模型回放测试本身还不能证明这项并发行为。这是验证缺口,没有声称已经复现原生异步回归。

第 2、3 项建议在合并前处理,第 6 项补齐针对性的行为验证。请保留现有的“捕获快照 → 后台执行 → 安全点采用”结构,以及压缩的独立请求通道。普通提前压缩应继续与 Main 重叠;模型切换的前置条件和实际容量不足,则分别有需要等待的理由。

@me2seeks
me2seeks force-pushed the feat/codex-native-compaction branch from 0090e94 to 4e9a9c3 Compare November 3, 2026 03:10
@github-actions github-actions Bot added the effort/XL Under 2500 readable lines label Nov 3, 2026

@M4n5ter M4n5ter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English

After reviewing this refactor again, the earlier concerns about scattered protocol handling, compaction results being passed through provider_options, and duplicated producer information in checkpoints have been substantively addressed.

The Responses adapter now encodes the compaction control and returns a clearly typed native result; the engine owns execution and adoption, while checkpoints derive producer model information from the original request. These responsibilities are clearer than before, and I currently see no reason to replace this with another architecture.

The additional background-concurrency test also has practical value: it waits for both the compaction request and the ordinary response request to arrive before checking that messages and tool results added during compaction are fully preserved, and that request retries still send the original content. This kind of test should remain.

I reran 111 facts/model tests, 7 native-compaction and background-concurrency integration tests, and 15 EventLog compaction-related tests locally; all passed. I have not confirmed a new blocking issue attributable to this layer.

However, this PR still depends on #6580, and the latest CI still has failures originating in that base layer. I suggest resolving #6580’s configuration-invalidation behavior and test-fixture updates first, then verifying CI for the whole stack. Cross-model state reuse and capacity handling before model switches can continue in the final two stages described in the issue.

简体中文

重新审查后,之前关于协议处理分散、压缩结果藏在 provider_options 中传递,以及检查点重复保存来源信息的意见,已经有了实质处理。

现在由 Responses 适配器编码压缩指令、返回明确类型的原生压缩结果,引擎负责执行压缩和采用结果;检查点通过原始请求读取来源模型信息。这套分工比之前清楚,我目前没有发现需要再换一套架构的理由。

补充的后台并发测试也有实际价值:它等待压缩请求和正常回复请求同时到达,再验证压缩期间新增的消息及工具结果被完整保留,以及请求重试仍发送原内容。这类测试应当保留。

我本地复跑了 facts/model 的 111 项测试、原生压缩及后台并发的 7 项集成测试,以及 EventLog 压缩相关的 15 项测试,均通过。当前没有确认属于这一层的新阻塞问题。

不过,这个 PR 仍依赖 #6580,最新 CI 也仍有基础层引起的失败。建议先解决 #6580 的配置失效行为及测试迁移问题,再确认整组改动的 CI。跨模型状态复用和切换前容量处理,继续按 issue 中后两阶段推进即可。

@me2seeks
me2seeks force-pushed the feat/codex-native-compaction branch 2 times, most recently from 3212509 to a4ac324 Compare November 3, 2026 07:10
Route subscription compaction through the Codex Responses trigger, persist producer-proven native state, and replay it through the existing source-fenced history lifecycle. Keep text compaction prompts available for other providers.

Refs #6579

Generated-by: Codex
Use one frozen protocol operation and typed terminal output. Encode the trigger in the Responses transport, derive checkpoint producer/model from the original request, and share the existing background concurrency/retry scenario with native compaction.

Refs #6579

Generated-by: Codex
@me2seeks
me2seeks force-pushed the feat/codex-native-compaction branch from a4ac324 to 8291caf Compare November 3, 2026 07:45
@M4n5ter
M4n5ter merged commit d0ae78d into rust-preview Nov 3, 2026
38 checks passed
@M4n5ter
M4n5ter deleted the feat/codex-native-compaction branch November 3, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XL Under 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants