Repository navigation
fix(codex): recover tool summaries after unfinished earlier work - #181718
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. What this changesAllow Codex to recover a final summary from complete current-turn evidence when earlier history contains unfinished tool work. Example: Earlier history contains unanswered tool call unfinished-prior-call; the current action completes once but returns no final text.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep open: this PR provides a focused recovery fix that current main still needs, with no actionable introduced defects found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Codex plugin projects verified transcript evidence into bounded history for an isolated, tool-free finalization turn, whose answer is persisted through the existing transcript owner. flowchart TD
A[Stored conversation] --> B[Current-turn evidence verifier]
B --> C[Prior-context projector]
C --> D[Bounded recovery history]
D --> E[Isolated Codex finalizer]
E --> F[Persisted final summary]
Technical reviewBest possible solution: Land this focused omission repair through the existing recovery owner once required CI passes, while retaining the broader failure-delivery issue. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically rejects an unfinished prior tool exchange at prependTo; the supplied native CLI A/B evidence confirms that failure and recovery without replaying the action. Is this the best way to solve the issue? The existing prior-context projector is the correct owner: omit its unusable replay prefix only after current evidence is verified, preserving pairing, provenance, uniqueness, and budget checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against dea6ff0cd0a3. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +9, Tests +55, Docs +3. Total +67 across 4 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)Reviewed October 26, 2026, 12:11 PM ET / 16:11 UTC (Revision 4). |
|
Added public-CLI boundary evidence to the PR body for the unchanged reviewed head @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Fresh exact-head native Codex CLI A/B proofCandidate The CLI first initializes the real native session. A preparation utility then appends one synthetic unanswered earlier tool call using the shipped public transcript SDK (runtime config prepared, normal append ownership; no raw DB writes). The current native turn invokes the advertised main, repetition 1{
"exitCode": 1,
"actionCount": 1,
"recoveryRequests": 0,
"persisted": false,
"prefixBeforeSha256": "602de726c2d04478dcc4099c5c1bdebba39adf852c1fed072af8598eae93fce9",
"prefixAfterSha256": "602de726c2d04478dcc4099c5c1bdebba39adf852c1fed072af8598eae93fce9",
"runtime": "codex",
"finalAnswer": []
}main, repetition 2{
"exitCode": 1,
"actionCount": 1,
"recoveryRequests": 0,
"persisted": false,
"prefixBeforeSha256": "d108d4576d8ede07a6692c8b7a527b10c5e3896d8f2210d136c1c186d73eb84a",
"prefixAfterSha256": "d108d4576d8ede07a6692c8b7a527b10c5e3896d8f2210d136c1c186d73eb84a",
"runtime": "codex",
"finalAnswer": []
}candidate, repetition 1{
"exitCode": 0,
"actionCount": 1,
"recoveryRequests": 1,
"persisted": true,
"prefixBeforeSha256": "e63756b4992cc5eb712e56f12e6d7f1cda84c72e57b9aaab0849eb04434510c0",
"prefixAfterSha256": "e63756b4992cc5eb712e56f12e6d7f1cda84c72e57b9aaab0849eb04434510c0",
"runtime": "codex",
"finalAnswer": [
"Recovered summary: the current action completed once; earlier context was omitted."
]
}candidate, repetition 2{
"exitCode": 0,
"actionCount": 1,
"recoveryRequests": 1,
"persisted": true,
"prefixBeforeSha256": "903f7f6c6b51c02ac9c016b05b66463585e8e7a068a13c29fc4fd0e3162fc10a",
"prefixAfterSha256": "903f7f6c6b51c02ac9c016b05b66463585e8e7a068a13c29fc4fd0e3162fc10a",
"runtime": "codex",
"finalAnswer": [
"Recovered summary: the current action completed once; earlier context was omitted."
]
}Both main runs reject recovery with Not fixed here: this does not explain or prevent an original empty native-model completion, solve all of #128916, repair historical unfinished actions, or prove external-model/channel delivery. It fixes only finalization after a verified complete current exchange when the prior replay suffix is unfinished. No source edits/pushes in this proof pass. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…prior-context-20261023 # Conflicts: # extensions/codex/src/app-server/settled-turn-prior-context.test.ts
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…nclaw#181718) fix(codex): judge tool-summary recovery on the current exchange, not earlier unfinished items Codex tool-summary recovery rejected a valid current exchange when earlier, unfinished prior-context items were present, so no summary was saved. Recovery now judges the current exchange on its own; earlier history is left untouched. Evidence: shipped `agent --local` on the real Codex 0.164.0 runtime with a local Responses fixture. On main recovery rejected the exchange as an incomplete pairing and saved no summary (twice); with this change it saved the summary with one action (twice), and the earlier event history was byte-identical in all four runs. The production files are unchanged by the later merge with main. Details: openclaw#181718 (comment). Items under "Not fixed here" in the body are not addressed. Thanks @indra622. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #128916
What Problem This Solves
Fixes missing Codex summaries when a completed tool turn follows an unfinished tool exchange in earlier conversation history.
User Impact
A turn with complete current evidence can recover its final answer without rerunning completed actions. Recovery may omit earlier conversation and reports that omission; persisted history stays intact.
Why This Change Was Made
At the verified current-turn boundary, an unfinished prior exchange makes the earlier replay prefix unusable. Omit that prefix as a whole and reuse the existing bounded omission notice. User steering within a completed exchange stays atomic. Current-turn pairing, provenance, call-ID uniqueness, content validation, and recovery eligibility keep their existing guards.
This addresses one recovery failure contributing to #128916; it does not claim to solve that issue in full or explain why a native model/server originally returned an empty final.
Latest integration
Head
293edef0c945e0745aca3e778404d5ee2dd8b3b9merges current main. The prior-context test conflict retains upstream’s consolidated layout, adds the pending-prior call-ID reuse row, and removes only the obsolete expectation that unfinished earlier context must reject the verified current turn. Production projector bytes are unchanged from provend7501c4cae3f9eb0d7905ee899d14e9a972b508a, so the linked public-CLI A/B proof carries without a new behavior claim.Fresh frozen install, changed-test format check, and both focused prior-context/native-finalizer files pass: 18/18 tests, including ordinary and oversized unfinished-prior native scenarios. Simplification retains the existing projector and omission owner, with no new seam: production +10/-1, tests +71/-16, docs +4/-1 against integrated main. No broader issue-closure claim.
Evidence
Fresh exact-head native CLI A/B proof: main
32276e16fb7807083d4452f2a9ec50084f6c95aetwice and candidated7501c4cae3f9eb0d7905ee899d14e9a972b508atwice. Fresh container builds passed. Shipped CLI launches real bundled Codex app-server 0.164.0 with a local Responses fixture. Main rejects the complete current exchange due to unfinished prior history; candidate persists the recovered summary. Each physical action occurs exactly once; prior transcript-event bytes remain identical after shutdown. No external-model or channel-delivery claim.transport-startup.test.tsdescendant-containment cases withProcessInspectionError(reason: permission) on macOS. Both exact failures also reproduce on the clean pinned base with an independent frozen install and the same test wrapper: 2 failed, 2 deselected, exit1 in 31.6 seconds. They are baseline-host permission failures; no permission/config changes or unrelated fixes were made. The two new native regressions passed in this run.Validation gaps: no live external provider/channel run or deployment. The first package-boundary typecheck lacked SDK declarations; the documented source typechecks subsequently passed. A missing required fixture option was corrected and the final candidate was reviewed again. The Codex extension lane is not green on this host: both process-inspection failures reproduce without this patch on the pinned base. No live containment claim is made from these failing tests; their finally blocks perform ownership-bound cleanup, but no separate post-hoc descendant-liveness receipt was retained.
Public CLI boundary proof (2026-10-23)
Addressing the requested entry-point proof on the reviewed head
c7d1b85cefaf230bf5b487ceb3102778ab898173. Separate normalpnpm build:runtimebuilds of candidate and pinned base3e4251331e83d844498fc66f70675f97f98616e5were exercised throughnode openclaw.mjs agent --local, with the real pinned Codex CLI 0.162.1. The parent independently reran both and inspected the persisted SQLite finalizer record and physical action-count file. The source checkout remains clean at the reviewed head; no code changes were needed.Scope and fault injection: a deterministic local HTTP Responses server supplies model responses; this is not real external-model, Gateway, channel-delivery, npm-installation, or deployment proof. The public CLI first creates isolated state, then a preparation utility seeds a synthetic unanswered earlier tool call through the public transcript SDK. The current turn uses the advertised
openclaw_direct.exectool to append one line to a task-owned file. Only after observing its completed tool output and physical count 1 does the provider inject one empty completion. The unmodified native launcher, product CLI, recovery owners, and persistence decide the outcome; no private finalizer is directly invoked for the current turn.Candidate: CLI exit 0, one recovery request, final answer persisted. Base negative control: CLI exit 1,
incomplete_pairing/context_unavailable, no recovery request or persisted answer. Both perform the action exactly once and preserve the prior event prefix byte-for-byte. Hashes below cover the exact previously stored event text/blob prefix, not the mutable whole database; independent synthetic sessions have different hashes. Observed task-owned processes exit and proof ports close.Redacted terminal output and read-only persistence measurements from the independent reruns:
Public entry command shape (synthetic identifiers and prompt redacted):
Entry SHA-256:
17aef9acdbe968fc07fa80685319c6fe974e019a89e0d657042b10129bc7ea51. Frozen task-local harness SHA-256:10cf2ef6dd9ddabf8d96f3b02a2576117f9f6fffb3b709e14b1728cb330e8fef. This extends the existing private-fixture evidence to the public CLI boundary; it does not establish natural empty-response causation or real-model tool selection. Maintainer review determines whether this satisfies the proof gate.Main integration (2026-10-25)
Updated head:
dbfed01061169f356193502f1371aa074e7cda8c, a non-force merge of main730a97454673f6382d960102f6a06ecf4869ff81into the existing PR branch. The single native-test scenario-list conflict retains both the unfinished-prior regressions and upstream prompt-less stranded-reply retry scenarios. The production change, prior-context test, and documentation are unchanged from the previously reviewed head; only the original four files differ from integrated main.Fresh integration checks: 97 focused tests across six files passed, including native finalizer and prompt-prefix stability coverage. An independent rerun of the prior-context and native-finalizer files passed all 22 tests. Four-file formatting, targeted type-aware lint, targeted typecheck, and the PR diff whitespace check passed. The worktree-local frozen install did not change the lockfile. Earlier public-CLI proof above remains evidence for its explicitly pinned earlier head; it was not rerun for this mechanical integration. New-head GitHub CI is tracked separately.
Follow-up main integration (2026-10-25)
Current head:
0e5e483b3dc0462df28fe4d8bc3e7a220266ff74, including fetched main40b3e0552180f0ba2416d6d6576579c50af8f69e. The renewed native-fixture conflict retains both unfinished-prior assertions and upstream same-run transient-retry assertions, including the upstream hidden-or-continuation condition. Production code, prior-context tests and docs remain unchanged from the original reviewed PR; the delta against integrated main remains the original four files. The local frozen install follows upstream's Codex 0.164.0 pin without changing dependency declarations or the lockfile.Focused verification: 99 tests across six files pass; formatting, targeted type-aware lint, typecheck and PR-diff whitespace checks pass. The last main-integration step adds only an unrelated upstream benchmark change, with affected source, tests, dependency files and the scoped PR delta verified unchanged. An independent exact-final-head rerun of prior-context and native-finalizer tests passed all 23 tests. Earlier CLI proof retains its explicitly stated earlier head and synthetic-provider scope; no new live-provider, Gateway or broad-suite claim is made. New-head GitHub CI is tracked separately.
Main integration and test consolidation (2026-10-26)
Current head:
d7501c4cae3f9eb0d7905ee899d14e9a972b508a, an ordinary merge of pinned main65112cda4acb357a13cd772641ed88acd9bb5759. The native-fixture conflict is resolved without restoring tests or fixtures retired by upstream's consolidation. Both unfinished-history regressions and their omission assertions remain, together with upstream prompt-less retry and same-run continuation coverage. Production code, prior-context tests and recovery documentation remain byte-identical to the original reviewed PR. The delta against integrated main remains four files (78 additions / 13 deletions); the import adjustment is needed because upstream removed its earlier transcript-append usage.Fresh verification: all 94 tests across six focused files pass, plus formatting, targeted type-aware lint, typecheck and PR-diff whitespace checks. The lower count reflects upstream's native-test consolidation, not removal of either PR regression. An independent exact-head rerun of prior-context and native-finalizer passed all 18 tests. The frozen worktree-local install preserves main's dependency declarations and lockfile. A separate merge-tree check against later live main
a14fa613c67820dd4b7884ee3ae661f3f942655cexited 0 without additional synchronization. Earlier CLI proof remains explicitly scoped to its earlier reviewed head and synthetic provider; no new live-model/Gateway proof is claimed. New-head hosted CI is tracked separately.Not fixed here
The original cause of empty native-model completions, all other #128916 cases, historical unfinished actions, and external-provider/channel delivery are not fixed or proven here. This repair only allows a verified complete current exchange to finalize when earlier unfinished context cannot form a replayable suffix.
Merge danger
Two-way door: revert restores earlier prior-context rejection; no schema/config migration. Blast radius is isolated Codex post-tool finalization when its earlier replay context contains an unfinished exchange. Existing current-turn validation and once-only execution remain intact.