Repository navigation
fix(codex): reset native context after history cuts - #155207
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 7:10 PM ET / 23:10 UTC (Revision 5). ClawSweeper reviewWhat this changesThe PR resets Codex’s native conversation context after successful rewinds and branch switches, documents the optional harness hook, and repairs supporting test fixtures. Merge readiness✅ Ready for maintainer review This remains a useful, distinct fix absent from current main and the latest release. The inspected behavior proof supports it, and no blocking correctness or security findings remain. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw stores the selected conversation history while its Codex plugin maintains a separate native thread. History cuts must invalidate that thread so the next model turn uses the selected history. flowchart TD
A[Rewind or branch switch] --> B[Validate selected history]
B --> C[Prepare native binding retirement]
C --> D[Commit transcript change]
D -->|Failure| E[Restore native binding]
D -->|Success| F[Release old subscription]
F --> G[Start fresh native thread from selected history]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +114, Tests +203, Docs +16. Total +333 across 15 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep transcript cuts and native-context retirement under the existing transactional lifecycle owner while preserving compaction continuity and failed-cut recovery. Do we have a high-confidence way to reproduce the issue? Yes: rewind an existing native conversation, reload, and ask for the previous answer. Current-main source preserves the native resume path, and the supplied before screenshot shows recall of the erased turn; this review did not execute a reproduction. Is this the best way to solve the issue? Yes: a transactional lifecycle hook addresses both successful cuts and rollback without misusing ordinary reset or disrupting compaction adoption. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d00afc6ae161. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
#155127 does not supersede this PR. The merged PR handles continuity after tool-heavy thread rotation caused by a fresh native start. This PR handles intentional transcript rewind/branch cuts and retires native context so erased turns cannot be recalled. The triggers, lifecycle boundary, and correctness requirements are distinct; please keep this PR open for its own verification and landing decision. Disposition: DO NOT CLOSE. |
|
The native output-fidelity fixture incorrectly required the completed command telemetry aggregate to duplicate all stdout. Codex 0.154.0 exposes that aggregate as nullable and fills it through a streaming subscriber independently of the canonical tool-response buffer. The observed CI completion retained exit code 0 but returned a null aggregate. This repair keeps completion/exit-code checks and directly verifies source/full-or-truncated raw response, the next actual provider HTTP request, and OpenClaw projected result. It adds null-aggregate coverage in both event orders. No production or dependency behavior changes. The original 12-file, two-worker shard passed locally unchanged (309 passed, one existing skip; 90.251s wall), so the upstream schedule was not reproduced. A controlled raw-response-drop mutation failed both new null-order cases; a synthetic native null-completion diagnostic passed both strict response budgets. Neither is a claim to fix Codex streaming telemetry. Measured one-worker costs: native two-case file 27.986s wall; unit 13-case file 26.824s wall, with the two added null-order cases 3ms each (6ms summed). Compilation dominates these cold command costs. Hosted successor proof passed: all 13 unit cases totaled 76ms, including 6ms for the two new null-aggregate cases. Both native cases passed; their exact durations were removed by the hosted log sanitizer, and no native file wall was printed. The owning 12-file shard passed 309 cases with one existing skip in 141.52s; that is a shard cost, not a file cost. Managed P0–P2 review is scoped-clean (0.94); all 20 selected checks passed (267.908s). All 20 standalone runs passed (280.157s combined), and all three original 12-file/two-worker shard runs passed 309 tests plus one existing skip (76.943s / 63.514s / 63.982s). Two projector sibling files passed all 44 cases (28.528s). Source hashes remained unchanged throughout. This completes the sole pending qualification item in the latest review. The remaining CI failure is a separate current-main workflow guard that mistakenly matches the observational REPLAY_PNPM_VERSION variable as a legacy version selector; it is being repaired at its test owner before refreshing this PR. |
Match the standalone legacy PNPM_VERSION identifier without rejecting the Windows replay workflow's observed REPLAY_PNPM_VERSION. Keep the separate pnpm-version input and pnpm/action-setup prohibitions intact. The exact current-main guard fails before this change and passes afterward; an injected legacy pin still fails. All 561 package acceptance tests pass (172.662s wall), with no production or workflow change. Repairs the current-main failure observed in CI run 35662101752 while validating #155207. Managed review is clean through P2.
Retire the native binding only when a local rewind or branch switch commits, so the next turn uses selected OpenClaw history. Reuse existing lease, rollback, and subscription cleanup ownership while preserving predecessor lineage and compaction continuity.
Launch generated command scripts through an immutable shell fixture so inherited write descriptors cannot cause ETXTBSY before process deadline tests start. Preserve real PATH lookup and process-tree assertions; model unregistered worktree cleanup accurately.
d8fd514 to
f63a61f
Compare
|
Merged via squash.
|
Match the standalone legacy PNPM_VERSION identifier without rejecting the Windows replay workflow's observed REPLAY_PNPM_VERSION. Keep the separate pnpm-version input and pnpm/action-setup prohibitions intact. The exact current-main guard fails before this change and passes afterward; an injected legacy pin still fails. All 561 package acceptance tests pass (172.662s wall), with no production or workflow change. Repairs the current-main failure observed in CI run 35662101752 while validating openclaw#155207. Managed review is clean through P2.
* fix(codex): reset native context after history cuts Retire the native binding only when a local rewind or branch switch commits, so the next turn uses selected OpenClaw history. Reuse existing lease, rollback, and subscription cleanup ownership while preserving predecessor lineage and compaction continuity. * test(qa-lab): avoid writable executable races in Mantis fixtures Launch generated command scripts through an immutable shell fixture so inherited write descriptors cannot cause ETXTBSY before process deadline tests start. Preserve real PATH lookup and process-tree assertions; model unregistered worktree cleanup accurately. * test(codex): assert output fidelity independently of telemetry
What Problem This Solves
Fixes native Codex conversations remembering erased turns after a successful rewind or branch switch.
User Impact
Rewinding or selecting an earlier branch now starts the next native turn from the selected conversation history. Invalid cuts and failed writes preserve the current conversation, and ordinary compaction retains native thread continuity. No configuration or data migration is required. The first turn after a history cut starts a fresh native thread and may lose native cache reuse; ordinary compaction keeps its existing continuity.
Why This Change Was Made
The local transcript rotated correctly, but its predecessor lineage allowed the native binding owner to resume the old Codex thread, including the removed context. A narrow optional harness lifecycle hook now retires that context at the successful history-cut transaction boundary. It reuses existing binding leases, rollback, and subscription cleanup; it preserves lineage and leaves compaction adoption unchanged.
Evidence
Live UI reproduction: rewind hid the second turn and reload preserved the shorter transcript, but the next model turn recalled the erased answer. The inspected synthetic before screenshot is attached. Live after-proof on product commit
6948b040cddpassed (successor commits change only tests and CI fixtures): the same existing native session was rewound through the Control UI, then reloaded with its restored composer text intact. Sending the identical recall prompt returnedQA388_READYfrom retained history, instead of the erasedQA389_SECOND_TURNreturned before the fix.Registered cross-owner regression: original production failed the native-thread assertion; the candidate passes with both a current binding and an exact recorded predecessor. The disposable diagnostic is retained as local evidence, outside product source.
Changed files: 63 cases pass, including failed-cut preservation, SQL rollback, active-thread refusal, and subscription cleanup before successor admission. Existing Gateway, transcript, deletion, binding, and compaction siblings: 245 cases pass in 81.313 seconds.
Required one-worker costs:
pnpm test src/config/sessions/session-accessor.sqlite-message-cut-native.test.ts --maxWorkers=120.556 seconds (11 cases);pnpm test extensions/codex/src/app-server/session-retirement.test.ts --maxWorkers=125.636 seconds (9 cases);pnpm test extensions/codex/harness.test.ts --maxWorkers=110.448 seconds (43 cases). Sixteen added cases report 4.687 seconds summed test-body time; command walls include compilation/imports and are not marginal CI-cost estimates. Original hosted CI passed all three owners: 11 native-cut cases totaled 6.795 seconds, 9 retirement cases 0.059 seconds, and 43 harness cases 8.502 seconds. These are summed case durations, not whole-file wall times.Final managed review is scoped-clean P0–P2. Selected checks pass, including the owning core test graph, core/extension types, scoped lint, SDK boundaries, storage and authority guards. The existing SDK surface budget now passes without changing its ceiling. Full
pnpm buildincluding Control UI assets passed in 239.850s on clean product commit6948b040cdd. All 1,548 UI assets verified. Successor-head CI is in progress.Additional real-provider proof: a fork retained the selected history without changing its parent; switching the parent to a preserved branch made its next reply recall that branch’s last answer. A subsequent tool run created a Unicode CSV and Markdown summary, computed the correct total, and opened the summary through the UI file viewer.
Original CI completed with 132 passing checks and 15 skips. The sole substantive failure was an unrelated Mantis fixture launch returning
ETXTBSYbefore its timeout assertions. A controlled held-writable-descriptor reproduction fails with the original generated executable and passes with the immutable shell launcher. The repair preserves PATH lookup, process-tree termination, and every existing assertion; fake Git cleanup now correctly reports an unregistered worktree. The exact original 73-file shard passed once without changes, which is recorded as nonreproduction, not proof of a fix.Fixture validation: 9 cases pass in 13.457 seconds with the required one-worker command, managed P0–P2 review is clean, and all 25 selected command statuses passed. The outer validation supervisor exited with signal 143; its original child continued, was joined, and its retained per-command summary confirms completion. The cause of the supervisor exit is unknown. Twenty standalone runs and three original-order 73-file/712-case shards all passed; 40 command/cleanup sibling cases also passed in 9.527 seconds. The first successor CI passed the repaired Mantis shard in 4m7s (9 changed cases totaled 7.497 seconds), then completed with 132 passing checks and 15 skips. Its sole substantive failure was a separate native output-fidelity assertion in an extension bundle; see the retained run.
Native output test repair: the pinned Codex runtime independently buffers the tool response, while its late streaming subscriber can leave the nullable completion aggregate empty. The test incorrectly required both outputs to duplicate the source. The successor retains command completion/exit-code checks and exact source, truncation, raw-response-to-next-HTTP-request, and projected-result assertions. Two added null-aggregate cases protect both event orders; discarding the raw response makes both fail. A temporary native notification diagnostic with a null aggregate passes all fidelity checks. No production or dependency changes are made, and the upstream telemetry race is not claimed fixed.
Output-test validation: 13 projector cases pass in 26.824 seconds wall (the two added cases total 6ms); both native cases pass in 27.986 seconds. All 20 selected checks and fresh managed P0–P2 review pass. The unchanged original 12-file plan passed 309 cases with one existing skip in 90.251 seconds, which is recorded as nonreproduction. Qualification is complete: all 20 standalone runs passed (280.157 seconds combined); all three original 12-file/two-worker shards passed 309 cases with one existing skip each (76.943 / 63.514 / 63.982 seconds); 44 owner sibling cases passed in 28.528 seconds. Source hashes remained unchanged, temporary diagnostics were restored, and all child processes were joined. The latest hosted native shard also passed all 309 cases with one existing skip; full new-head CI is still running.