feat(codex): bind context-engine projections to codex threads#82351
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: not applicable. as a feature PR. The relevant behavior is demonstrated by redacted live gateway logs in the PR body and focused regression coverage on the PR head. Real behavior proof Next step before merge Security Review detailsBest possible solution: Have a maintainer review and land the additive Codex/context-engine projection contract once normal CI and branch gates pass. Do we have a high-confidence way to reproduce the issue? Not applicable as a feature PR. The relevant behavior is demonstrated by redacted live gateway logs in the PR body and focused regression coverage on the PR head. Is this the best way to solve the issue? Yes, with maintainer review: the PR uses an additive SDK field and binds projection epochs in the existing Codex thread lifecycle, which is the narrow maintainable place for persistent app-server thread coherence. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against a70c90a52bf1. |
1c0ec04 to
cca60ad
Compare
…aw#82351) * feat(codex): bind context-engine projections to codex threads * fix: harden Codex context-engine projection * fix: remove unused Codex projection helper * fix(codex): adopt compacted context-engine transcripts
…aw#82351) * feat(codex): bind context-engine projections to codex threads * fix: harden Codex context-engine projection * fix: remove unused Codex projection helper * fix(codex): adopt compacted context-engine transcripts
…aw#82351) * feat(codex): bind context-engine projections to codex threads * fix: harden Codex context-engine projection * fix: remove unused Codex projection helper * fix(codex): adopt compacted context-engine transcripts
…aw#82351) * feat(codex): bind context-engine projections to codex threads * fix: harden Codex context-engine projection * fix: remove unused Codex projection helper * fix(codex): adopt compacted context-engine transcripts
…aw#82351) * feat(codex): bind context-engine projections to codex threads * fix: harden Codex context-engine projection * fix: remove unused Codex projection helper * fix(codex): adopt compacted context-engine transcripts
…aw#82351) * feat(codex): bind context-engine projections to codex threads * fix: harden Codex context-engine projection * fix: remove unused Codex projection helper * fix(codex): adopt compacted context-engine transcripts
…aw#82351) * feat(codex): bind context-engine projections to codex threads * fix: harden Codex context-engine projection * fix: remove unused Codex projection helper * fix(codex): adopt compacted context-engine transcripts
What
Adds Codex app-server support for context-engine-owned thread-bootstrap projection epochs. When an owning context engine provides a bootstrap projection, Codex binds that projection metadata to the backend thread and starts a new backend thread when the context-engine epoch or compatible runtime policy changes.
Why
Lossless/context-engine compaction should own the compacted context that gets projected into Codex. Re-projecting the full context every turn wastes prompt space, while continuing the same Codex backend thread after context-engine compaction leaves Codex and the context engine out of sync.
Changes
Testing
git diff --check HEAD~1..HEADCI=true pnpm test -- extensions/codex/src/app-server/compact.test.ts extensions/codex/src/app-server/run-attempt.context-engine.test.ts extensions/codex/src/app-server/context-engine-projection.test.tsFocused local regression output:
Real behavior proof
Behavior addressed: Lossless Claw can project Codex app-server context using thread-bootstrap epochs, reuse a matching bootstrap binding without re-projecting full context, start a fresh Codex backend thread when the runtime binding becomes incompatible, and invalidate the Codex thread binding after context-engine-owned compaction. The Clawsweeper successor-transcript compaction finding is addressed in code and covered by the focused regression test.
Real environment tested: Live OpenClaw gateway on Josh's Telegram OpenClaw topic, using the OpenAI Codex app-server runtime with Lossless Claw active as the context engine. Runtime evidence came from today's gateway log. The live checkout was branch
josh/context-engine-bootstrap-projectionatcca60ade0eduring the manual compaction; the latest successor-handle fix commita3f06bf160was verified locally in the PR worktree.Exact steps or command run after this patch: Inspected today's runtime log around Josh's manual compact at 2026-05-15 18:25 PDT and searched for Lossless/Codex context-engine compaction, projection, and binding events. Also reran focused local verification with
git diff --check HEAD~1..HEADandCI=true pnpm test -- extensions/codex/src/app-server/compact.test.ts extensions/codex/src/app-server/run-attempt.context-engine.test.ts extensions/codex/src/app-server/context-engine-projection.test.ts.Evidence after fix: Redacted runtime log excerpts from the live gateway showing manual context-engine-owned compaction:
Redacted runtime log excerpt from the next live topic turn showing the invalidated binding caused a fresh thread-bootstrap projection and new Codex binding:
Earlier redacted live runtime excerpt from the same branch showing a matching bootstrap binding can be reused without re-projecting:
Focused local regression output for the successor-transcript compaction path:
Observed result after fix: The live gateway logs show Lossless Claw performing context-engine compaction, Codex completing context-engine-owned app-server compaction with
codexThreadBindingInvalidated=true, the next turn projecting because the thread binding was missing, and Codex writing a fresh context-engine thread binding. The earlier live logs also show Codex reusing a matching bootstrap binding without re-projecting. The focused regression verifies the Clawsweeper P2 contract surface: owning context-engine compaction sends successorsessionId/sessionFiletomaintain()and clears both original and successor Codex app-server bindings.What was not tested: The live manual compact did not return a successor transcript in the observable logs, and the deployed checkout was not yet at
a3f06bf160. The successor-handle behavior is covered by the focused regression because it is theContextEngine.compact()contract surface Clawsweeper flagged.