Repository navigation
Conversation
…s a terminal result stripInvalidThinkingSignatures intentionally exempts the latest assistant turn (providers reject a modified latest thinking block), expecting a corrupted latest block to flow through stream recovery instead. But when the provider rejects the replayed signature, the 400 can surface as a resolved result message (stopReason "error" + errorMessage) rather than an in-stream error event or a thrown rejection. pumpStreamWithRecovery only handled the error-event and throw carriers, so recovery never fired and the session was rejected on every replay until a manual restart. Recover this carrier too: when the terminal result is a recoverable thinking error and no content has streamed, retry once without thinking blocks and notify, so the persisted transcript is repaired. Adds a regression test for the result-message carrier.
|
Codex review: needs maintainer review before merge. Reviewed June 22, 2026, 12:38 AM ET / 04:38 UTC. Summary PR surface: Source +21, Tests +68. Total +89 across 2 files. Reproducibility: yes. at source level: current main drains the stream, awaits Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Merge this narrow terminal-result carrier fix after maintainers accept the session-state repair tradeoff and VE-816 proof equivalence, while keeping the broader Anthropic replay cluster open. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main drains the stream, awaits Is this the best way to solve the issue? Yes for the terminal-result carrier: the existing recovery wrapper already owns one-shot Anthropic thinking replay recovery for stream-error and thrown-error carriers, so checking the no-output terminal result there is the narrowest maintainable fix. It is not the full solution for the broader Anthropic thinking-signature create/replay cluster. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a594d2ce7325. Label changesLabel justifications:
Evidence reviewedPR surface: Source +21, Tests +68. Total +89 across 2 files. View PR surface stats
Acceptance criteria:
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
|
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(embedded-agent): recover thinking-signature rejection delivered a… This is item 1/1 in the current shard. Shard 1/4. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Closing due to inactivity. |
Problem
A session can wedge and stop responding after an Anthropic invalid-thinking-signature error: every subsequent turn 400s on replay (
replay_invalid) and never recovers until the gateway is manually restarted. The failing turn produces no visible output — the model call is rejected before anything streams.Root cause
wrapAnthropicStreamWithRecoveryalready recovers an invalid-thinking-signature 400 when it arrives as an in-stream error event or as a thrown rejection — it retries once without thinking blocks and repairs the session.But the same 400 can surface a third way: as a terminal result message. The stream resolves normally and
result()returns anAssistantMessagewithstopReason: "error"and anerrorMessagecarrying theinvalid_request_error("Invalid signature in thinking block"). No error event is emitted and nothing is thrown, so neither existing recovery branch fires and the wrapper returns the error result unchanged.Because the latest-turn exemption in
stripInvalidThinkingSignaturesintentionally lets a corrupted latest thinking block flow through to this recovery path, a session that hits this carrier 400s on every replay and stays wedged.Fix
Handle the terminal-result carrier in
pumpStreamWithRecovery, the same way as the existing error-event branch: afterresult()resolves, if the turn produced no output and the result is a recoverable Anthropic thinking error, markrecoveredAnthropicThinking, log a[session-recovery]warning, and retry once without thinking blocks (retryStreamWithoutThinking).!yieldedOutput: a signature 400 is rejected before any content streams, so the branch only fires for a turn that produced no visible output — a turn that already streamed content is untouched.shouldRecoverAnthropicThinkingError(result, sessionMeta)predicate, so only invalid-thinking-signature errors trigger recovery; any other terminal error is returned unchanged.thinking.ts; no change to the streaming/error-event paths or tostripInvalidThinkingSignatures.This is a narrow recovery-carrier follow-up within the open Anthropic invalid-thinking-signature cluster (canonical: #92201). It closes the terminal-result gap left by the error-event / raw-error recovery in #92916 and the durable transcript repair in #92286; it is not the create-side / replay-policy fix tracked by the canonical issue.
Testing
Adds a regression test in
thinking.test.ts: "recovers a thinking-signature rejection delivered as a terminal result message". The provider 400 is delivered only viaresult()(stopReason: "error"+errorMessage) with no chunks streamed first. It asserts the wrapper retries once (callCount === 2), notifies recovery exactly once (onRecoveredAnthropicThinking), starts the retry context with the thinking block stripped (keeps the visible text), and resolves to the recovered final message. Reverting the fix makes the test fail — the error result is returned and the session wedges.Real behavior proof
stopReason: error, no streamed content) previously left the session wedged — every replay re-hitreplay_invalidand the turn produced no output until a manual gateway restart. After the fix, the recovery path strips the rejected thinking blocks and retries the turn once, and the session continues on its own.claude-opus-4-8, WhatsApp channel,sessionKey=agent:main:main. The running build is VE-816, an independent implementation of the same terminal-result-carrier recovery this PR adds (detect the recoverable thinking-signature error on a no-output terminal result → strip thinking blocks → retry once). It is a separate build, so the recovery log wording differs — see "What was not tested".Invalidsignatureinthinkingblockrejection on real inbound turns; inspected the gateway's structured runtime logs withopenclaw logs(file/tmp/openclaw/openclaw-2026-06-19.log) and cross-checked the self-hosted Langfuse trace store.openclaw logs(phone numbers and message bodies removed;request_idis already runtime-hashed):stopReason: errorwith theinvalid_request_error, and a clean retry GENERATION ran ~3.4s later in the same trace.[session-recovery]lines, and each wedged turn ended with empty assistant output.stripped thinking blocks/repaired rejected thinking replayrather than this branch's phrasing). No synthetic or forced reproduction was used; every capture is an organic production occurrence.