fix(codex): stop injecting mirrored history into prompts#88262
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed May 30, 2026, 3:06 AM ET / 07:06 UTC. Summary PR surface: Source -75, Tests -39. Total -114 across 6 files. Reproducibility: yes. source inspection gives a high-confidence reproduction path: append mirrored session messages, start default Codex without an active context engine or usable binding, and current main can project that history into turn/start input. I did not run the harness because this review was read-only. Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Rebase onto current main, remove both no-context mirrored-history projection paths while preserving explicit context-engine projection, keep focused startup/resume/rotation/hook coverage, and add real Codex app-server diagnostic proof or a maintainer proof override. Do we have a high-confidence way to reproduce the issue? Yes, source inspection gives a high-confidence reproduction path: append mirrored session messages, start default Codex without an active context engine or usable binding, and current main can project that history into turn/start input. I did not run the harness because this review was read-only. Is this the best way to solve the issue? Not yet as submitted: the direction is plausible, but the branch is stale against current main and the fallback-removal policy needs explicit maintainer acceptance plus real behavior proof. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 26bf8f0dc87b. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source -75, Tests -39. Total -114 across 6 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
e2be8eb to
04a4427
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04a4427d0c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Codex app-server threads own conversation continuity. The mirrored | ||
| // OpenClaw transcript is persistence/search state. Context-engine output is | ||
| // rendered into the prompt/developer instructions, not parallel history. | ||
| const codexModelInputHistoryMessages: typeof historyMessages = []; |
There was a problem hiding this comment.
Preserve context for transient Codex starts
When the native tool surface is disabled (for example toolsAllow: [], node exec, or an active OpenClaw sandbox), thread-lifecycle.ts deliberately ignores any existing binding and starts a transient thread instead of resuming Codex history. With the mirrored-history projection removed and codexModelInputHistoryMessages hard-coded to [], those transient no-context-engine turns now send only the current prompt, so users continuing a restricted/sandboxed Codex conversation lose all prior context. Keep the mirrored projection for this non-native path, or make the transient start resume/receive equivalent history.
Useful? React with 👍 / 👎.
Summary
Stop Codex app-server turns from injecting the mirrored OpenClaw transcript back into Codex model-input surfaces.
The important split is:
Detailed explainer
Before this change, a default Codex run without an active context engine could still call the context-engine projection helper and rewrite the current prompt with mirrored OpenClaw history. A same-area rotation path could do the same after starting a fresh native thread. Those fallbacks were intended as bridges for transient/native-disabled startup states, but they mean Codex can receive a second shadow transcript even though Codex already maintains its own native thread state.
That is the source of the context bloat: the OpenClaw mirror contains records useful for OpenClaw bookkeeping, search, display, and failure snapshots, but it is not the authoritative Codex conversation. Re-injecting it into the current turn makes the prompt larger, can duplicate history, and can pollute prompt/cache behavior without adding real Codex thread continuity.
This PR removes that fallback and makes the model-input surfaces explicit:
Verification
node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-codex.config.ts extensions/codex/src/app-server/run-attempt.context-engine.test.ts extensions/codex/src/app-server/attempt-context.test.ts extensions/codex/src/app-server/run-attempt.hooks.test.ts extensions/codex/src/app-server/run-attempt.test.ts -t "context-engine|fires llm_input|emits gated model-call content diagnostics|applies before_prompt_build|does not inject mirrored history|does not inject newer mirrored history|does not project mirrored messages|stale thread-bootstrap|reads and compares thread-bootstrap"git diff --checkpnpm exec oxfmt --check --threads=1 extensions/codex/src/app-server/attempt-context.test.ts extensions/codex/src/app-server/attempt-context.ts extensions/codex/src/app-server/run-attempt.context-engine.test.ts extensions/codex/src/app-server/run-attempt.hooks.test.ts extensions/codex/src/app-server/run-attempt.test.ts extensions/codex/src/app-server/run-attempt.ts.agents/skills/autoreview/scripts/autoreview --mode local --prompt-file /tmp/codex-mirror-projection-autoreview.mdReal behavior proof
Behavior addressed: Codex app-server turns no longer inject mirrored OpenClaw transcript history into Codex prompt/model-input surfaces; active context-engine output remains available through the rendered prompt/developer-instruction path.
Real environment tested: local OpenClaw Codex extension Vitest harness in this checkout.
Exact steps or command run after this patch: the focused Vitest command, diff whitespace check, oxfmt check, and local autoreview commands listed above.
Evidence after fix: focused Vitest passed 31 tests across 4 files; diff check and oxfmt passed; autoreview reported no accepted/actionable findings.
Observed result after fix: tests assert default Codex startup/resume, stale thread-bootstrap fallback, before_prompt_build, llm_input, and model-call diagnostics do not contain mirrored prior context, while context-engine projection lifecycle tests still pass.
What was not tested: full repository CI was not run locally before PR creation.