Repository navigation
fix: Claude CLI forgets announced sub-agent results on the next turn - #164175
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 real behavior proof before merge. What this changesThis PR carries recorded completion exchanges into authorized Claude CLI resumes and reports a metadata-only gap when replay is withheld. Example: A child reports that 17 × 23 equals 391, then the requester resumes its earlier Claude session.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 3 items remain This PR addresses a documented current bug with a focused transcript-owned repair; no introduced correctness defect was identified. Priority: P1 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe CLI history owner reads canonical conversation rows, prepares bounded context, and passes it through the account-authorized execution transport to Claude. flowchart LR
A[Child completion] --> B[Canonical transcript]
B --> C[CLI history owner]
D[History account authority] --> C
C --> E[Resume prompt renderer]
E --> F[Execution authority check]
F --> G[Claude CLI session]
Technical reviewBest possible solution: Keep bounded completion recovery in the canonical transcript owner, preserving native continuity and the existing account boundary. Do we have a high-confidence way to reproduce the issue? Current-main source matches the linked official-release trace: the announcement preserves the old binding while its assistant row suppresses the gap notice; no target code was executed during this review. Is this the best way to solve the issue? The transcript-derived repair avoids competing persistence and preserves account authorization, bounded context, original user text, and native-session continuity. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0d22f2ae3431. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: Existing account and live-writer checks remain authoritative, with no concrete bypass identified. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +117, Tests +247, Docs +17. Total +381 across 11 files. Added test files: 2. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 (14 earlier review cycles; latest 8 shown)
Reviewed October 13, 2026, 5:21 PM ET / 21:21 UTC (Revision 15). |
265e715 to
1c8fad9
Compare
|
Note for the maintainer: the one open item here is the storage review checkpoint in What triggers the checkpoint: one optional persisted field, The contract to accept, as a whole:
Alternatives that avoid new persistence, and why this PR does not use them:
What would help: either record acceptance of the contract above, or say which part to change (a smaller bound, prompt-only carry, or one of the alternatives). The carried context has one owner ( |
1111b7b to
2cef489
Compare
- A preserved inter-session turn that runs outside the bound native CLI session reports its prompt and reply; the binding owner stores them on that binding, bounded like other context blocks, only when the auth identity matches. - The next turn that resumes the bound session prepends them once as a marked context block; any completed turn in that session consumes them, and a fresh session recovers them from saved history instead. - The completion turn's tool projection, MCP configuration, and loopback grant are unchanged. - A real-seam regression covers continuity and denial; store guard, resume-context order, and chat-history dedupe tests cover the new binding field. - The Claude CLI Gateway live announce probe now sends one more requester turn and checks Claude's transcript for the session it resumed. - CLI backend and sub-agent tool policy docs describe the contract.
2cef489 to
ad81e2b
Compare
…ce probe The live CLI-backend announce probe searched the resumed Claude session's user turns for the inter-session prompt envelope. A completion saved without a user row renders a reply-only record, so the authorized branch failed even when the resumed session received the result; when the handoff resumed the bound session instead, the probe matched the handoff prompt itself. Parse the marked context blocks of the follow-up turn and match the record's source and reply. Whether the handoff resumed the bound session (prompt drift only) or ran in its own session (an MCP hash change) is recorded, not asserted: the follow-up turn owes the record either way.
A completion handoff resumes the requester's bound Claude session when only prompt content drifted, and runs in its own session when its MCP projection hashes differently. The transcript does not record which one happened, yet the carried-completion label told Claude the events arrived in a separate session, and the session-gap note for a withheld login said they occurred outside this session. Both were wrong in the resumed case. Say what is known: the completion events were recorded in the conversation since the session's last reply here, and the session may already hold some of them. The gap note counts preserved turns with the same wording, and the prompt-text stripper recognizes it like the existing notes. The account gate and the bounded carry are unchanged.
Keep completion recovery in the canonical transcript owner, reuse bounded context rendering, and preserve account-authorized replay. Retain focused history, renderer, and import regressions; remove duplicate live proof scaffolding. Mark historical facts and preserve original user transcript text. Co-authored-by: Mitchell Etzel <[email protected]>
# Conflicts: # src/gateway/cli-session-history.routed-prompts.test.ts
|
Merged via squash.
|
|
Thanks @steipete! |
…penclaw#164175) * fix(agents): carry isolated CLI completion turns into the next resume - A preserved inter-session turn that runs outside the bound native CLI session reports its prompt and reply; the binding owner stores them on that binding, bounded like other context blocks, only when the auth identity matches. - The next turn that resumes the bound session prepends them once as a marked context block; any completed turn in that session consumes them, and a fresh session recovers them from saved history instead. - The completion turn's tool projection, MCP configuration, and loopback grant are unchanged. - A real-seam regression covers continuity and denial; store guard, resume-context order, and chat-history dedupe tests cover the new binding field. - The Claude CLI Gateway live announce probe now sends one more requester turn and checks Claude's transcript for the session it resumed. - CLI backend and sub-agent tool policy docs describe the contract. * fix(agents): replay carried CLI exchanges only under the history account boundary - The resume renderer prepends pending completion exchanges only when the turn holds the CLI history writer, the authority that already gates saved-history recovery - Settlement keeps no exchange for a binding without an auth epoch (opaque native login) - Regression covers a named account (carried once), an opaque native login (nothing kept) and an identity-less login whose token is replaced (withheld and dropped) - The live continuity probe expects the exchange only when the requester's history boundary is known - Docs state the account requirement * fix(agents): carry completion replies from the canonical transcript - Drop the persisted unseenTurns binding field, its settlement (settlePreservedCliSessionTurn) and the cliUnseenTurn run meta; the native binding contract is back to main's - Derive the carried context at resume time from the requester transcript: completion replies saved after the bound session's last ordinary Claude reply, recognized by their announce run id (announce:) or by a saved user row with completion provenance, newest 8, each bounded like context JSON - Replay still requires the turn's CLI history writer; without it the session-gap note now counts those completion turns instead of treating the completion reply as the last turn the session saw - Add isAnnounceIdempotencyKey next to buildAnnounceIdempotencyKey - Regression harness mirrors the Gateway: completions run under the announce key and save no user row; credential replacement covers a named account as well as an identity-less login - Move the transcript-derivation unit test to session-history.preserved-turns.test.ts (line cap) * fix(agents): name carried completion turns as delivered events - Label the carried block as completion events delivered in a separate session, each with the reply sent then, and give each record its source tool; with only a bare reply, installed Claude answered the next message as if no completion had arrived - Read the transcript run id with asOptionalRecord - Keep the preserved-turn check inside session-history; input-provenance is unchanged - Publish the runtime config snapshot in the regression harness, as the sibling attempt tests do since openclaw#169714 - Pin the newest-8 bound in the preserved-turns test * test(gateway): match the carried completion record in the live announce probe The live CLI-backend announce probe searched the resumed Claude session's user turns for the inter-session prompt envelope. A completion saved without a user row renders a reply-only record, so the authorized branch failed even when the resumed session received the result; when the handoff resumed the bound session instead, the probe matched the handoff prompt itself. Parse the marked context blocks of the follow-up turn and match the record's source and reply. Whether the handoff resumed the bound session (prompt drift only) or ran in its own session (an MCP hash change) is recorded, not asserted: the follow-up turn owes the record either way. * fix(agents): describe carried completions without naming where they ran A completion handoff resumes the requester's bound Claude session when only prompt content drifted, and runs in its own session when its MCP projection hashes differently. The transcript does not record which one happened, yet the carried-completion label told Claude the events arrived in a separate session, and the session-gap note for a withheld login said they occurred outside this session. Both were wrong in the resumed case. Say what is known: the completion events were recorded in the conversation since the session's last reply here, and the session may already hold some of them. The gap note counts preserved turns with the same wording, and the prompt-text stripper recognizes it like the existing notes. The account gate and the bounded carry are unchanged. * fix(agents): simplify resumed Claude completion context Keep completion recovery in the canonical transcript owner, reuse bounded context rendering, and preserve account-authorized replay. Retain focused history, renderer, and import regressions; remove duplicate live proof scaffolding. Mark historical facts and preserve original user transcript text. Co-authored-by: Mitchell Etzel <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Mitchell Etzel <[email protected]>
…164175) * fix(agents): carry isolated CLI completion turns into the next resume - A preserved inter-session turn that runs outside the bound native CLI session reports its prompt and reply; the binding owner stores them on that binding, bounded like other context blocks, only when the auth identity matches. - The next turn that resumes the bound session prepends them once as a marked context block; any completed turn in that session consumes them, and a fresh session recovers them from saved history instead. - The completion turn's tool projection, MCP configuration, and loopback grant are unchanged. - A real-seam regression covers continuity and denial; store guard, resume-context order, and chat-history dedupe tests cover the new binding field. - The Claude CLI Gateway live announce probe now sends one more requester turn and checks Claude's transcript for the session it resumed. - CLI backend and sub-agent tool policy docs describe the contract. * fix(agents): replay carried CLI exchanges only under the history account boundary - The resume renderer prepends pending completion exchanges only when the turn holds the CLI history writer, the authority that already gates saved-history recovery - Settlement keeps no exchange for a binding without an auth epoch (opaque native login) - Regression covers a named account (carried once), an opaque native login (nothing kept) and an identity-less login whose token is replaced (withheld and dropped) - The live continuity probe expects the exchange only when the requester's history boundary is known - Docs state the account requirement * fix(agents): carry completion replies from the canonical transcript - Drop the persisted unseenTurns binding field, its settlement (settlePreservedCliSessionTurn) and the cliUnseenTurn run meta; the native binding contract is back to main's - Derive the carried context at resume time from the requester transcript: completion replies saved after the bound session's last ordinary Claude reply, recognized by their announce run id (announce:) or by a saved user row with completion provenance, newest 8, each bounded like context JSON - Replay still requires the turn's CLI history writer; without it the session-gap note now counts those completion turns instead of treating the completion reply as the last turn the session saw - Add isAnnounceIdempotencyKey next to buildAnnounceIdempotencyKey - Regression harness mirrors the Gateway: completions run under the announce key and save no user row; credential replacement covers a named account as well as an identity-less login - Move the transcript-derivation unit test to session-history.preserved-turns.test.ts (line cap) * fix(agents): name carried completion turns as delivered events - Label the carried block as completion events delivered in a separate session, each with the reply sent then, and give each record its source tool; with only a bare reply, installed Claude answered the next message as if no completion had arrived - Read the transcript run id with asOptionalRecord - Keep the preserved-turn check inside session-history; input-provenance is unchanged - Publish the runtime config snapshot in the regression harness, as the sibling attempt tests do since #169714 - Pin the newest-8 bound in the preserved-turns test * test(gateway): match the carried completion record in the live announce probe The live CLI-backend announce probe searched the resumed Claude session's user turns for the inter-session prompt envelope. A completion saved without a user row renders a reply-only record, so the authorized branch failed even when the resumed session received the result; when the handoff resumed the bound session instead, the probe matched the handoff prompt itself. Parse the marked context blocks of the follow-up turn and match the record's source and reply. Whether the handoff resumed the bound session (prompt drift only) or ran in its own session (an MCP hash change) is recorded, not asserted: the follow-up turn owes the record either way. * fix(agents): describe carried completions without naming where they ran A completion handoff resumes the requester's bound Claude session when only prompt content drifted, and runs in its own session when its MCP projection hashes differently. The transcript does not record which one happened, yet the carried-completion label told Claude the events arrived in a separate session, and the session-gap note for a withheld login said they occurred outside this session. Both were wrong in the resumed case. Say what is known: the completion events were recorded in the conversation since the session's last reply here, and the session may already hold some of them. The gap note counts preserved turns with the same wording, and the prompt-text stripper recognizes it like the existing notes. The account gate and the bounded carry are unchanged. * fix(agents): simplify resumed Claude completion context Keep completion recovery in the canonical transcript owner, reuse bounded context rendering, and preserve account-authorized replay. Retain focused history, renderer, and import regressions; remove duplicate live proof scaffolding. Mark historical facts and preserve original user transcript text. Co-authored-by: Mitchell Etzel <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Mitchell Etzel <[email protected]> (cherry picked from commit d472fc5) Backport note: semantic port onto 2026.10.5. The release line lacks the Claude session-gap note (#168726/#168781), createCliCurrentPromptRenderer and cli-session-history.prompt-text.ts, so this keeps only the completion carry: session-history classifies Claude replies from the canonical transcript and renders the newest 8 preserved/announce exchanges since the last ordinary reply for a resumed claude-cli native session; prepare.ts prepends them (after any drift note) only when the turn holds the CLI history writer, via the renamed prependCliSessionResumeUserContext. Auth-boundary reasons already return before the transcript read, so withheld turns carry nothing. Gap-note wording, its stripper regex and their routed-prompt/dedupe test cases are dropped; docs say withheld content is not replayed. Renderer tests target the release helper; the preserved-turns test drops gap-note and admission assertions.
Fixes #171195
Related: #159512 (completion-session isolation), #154716 (native-login history ownership).
What Problem This Solves
A Claude CLI requester can announce a completed sub-agent's result, then resume an older native session on the next user turn and claim that the child has not reported back.
User Impact
The next resumed turn receives recorded completion exchanges when its existing history account boundary permits replay. When content is withheld, the turn receives a metadata-only gap notice that includes those completions. Tool restrictions and account boundaries stay in place.
Why This Change Was Made
The CLI history owner reads pending completion exchanges from the canonical transcript, distinguishing ordinary replies, state-preserving handoffs, and background refreshes. An ordinary reply consumes the carry. The newest eight exchanges use the existing context JSON sanitizer and its 2,000-character string limit. The renderer requires the existing history writer; the existing transport revalidates that authority immediately before disclosure. No parallel store, schema change, or new configuration is introduced.
The wording covers both isolated and already-resumed completion turns, and tells the model to verify current facts before acting on historical records. The original user prompt remains the stored transcript input, and native-history import strips the marked context.
Original fix by @etzelm; maintainer cleanup consolidates rendering in the transcript owner, removes duplicate sanitization and exports, and replaces the large subprocess/live-probe additions with focused owner regressions.
Evidence
PR CI is the test gate under the maintainer's October 13, 2026 proof policy. Local tests, typechecks, negative controls, live Gateway proofs, Crabbox, and Testbox were intentionally skipped. No contributor runtime code executed on the host.
Regression coverage for CI:
preserved Claude turns > carries completion exchanges since the last ordinary reply, or counts them when content is withheld: real transcript writes/readback, reply-only announcements, queued provenance, background refreshes, fresh-session exclusion, one-turn consumption, bounded carry and sanitization.CLI resume user context: drift ordering, fresh-session exclusion, and withholding without the history writer.imported Claude history merge > shows a resumed turn carrying unseen exchanges once: marked completion context imports without a duplicate user turn, with and without drift.Changed-file oxlint and oxfmt pass. The parent install lacks the unrelated Solid lint plugin, so local lint used the repository's core rules with only the
ui/**/*.tsxoverride omitted; no changed file matches that override. Deslop removed redundant production helpers and duplicate proof scaffolding. Independent Codex autoreview: scoped-clean through P2; no actionable findings. The reviewed production patch is unchanged by the main merge; its only conflict retained main's reduced routed-prompt test matrix and added the new completion-gap case. Exact-head CI run 38468757728 passed on70b6de0a26bd9ff568cd7700e42748a98bcc3358: changed Node/Bun test lanes, production types, all core test-type shards, lint, docs, source/architecture guards, andopenclaw/ci-gate. No failed checks or inherited-failure exceptions. The only merge conflict was the routed-prompt test matrix; main's reduction was retained with one new completion-gap case.Source/history confirmation: main's
renderClaudeSessionGapchooses the latestclaude-cliassistant row without distinguishingannounce:replies;subagent_announcepreserves the requester binding. That combination both loses the carried result and hides the metadata gap. The original gap change is #168726. Collision checks found only this PR for #171195.ClawSweeper's exact-head review (October 13, 21:21 UTC) reports no code findings and explicitly identifies no concrete account-boundary bypass. The topology-wording finding is resolved; the older live-probe matcher finding is superseded by removal of that optional probe. Its remaining security/merge-risk attention is an evidence request for live completion/resume and final-input authority-denial traces. Per the maintainer's explicit proof policy for this task, PR CI is the proof; those proof-only requests do not add live, negative-control, or local test requirements. Existing writer/account assertions remain intact. Earlier persisted-binding concerns are superseded by the transcript-only design. There were no human review comments.
Diff against merged main: production +136/-19 (net +117), tests +253/-6 (net +247), docs +18/-1 (net +17); 11 files, +407/-26 overall. No new timers, sleeps, subprocesses, or Gateway boots; local test wall time is intentionally unmeasured. CI recorded the transcript regression at 1,297 ms (one test; 14.32 s Vitest / 16.49 s shard wall including imports), the three new renderer cases at 2 ms each (the existing file's full run: eight tests, 43.38 s Vitest / 45.27 s shard wall, dominated by pre-existing runtime imports), and the two import cases at 32 ms and 10 ms. No additional subprocess harness is needed for these owner contracts. Production growth is necessary to classify the previously unrepresented completion boundary and render its bounded context; unrelated deletions were not used to meet a negative-LOC target.