You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the V2 session core, replaying history that contains an errored assistant message can produce a request Anthropic rejects with a 400 when extended thinking is enabled.
reuseProviderMetadata requires message.error === undefined (packages/core/src/session/runner/to-llm-message.ts:114), so an aborted/failed step drops all reasoning state on replay — both signed thinking (anthropic.signature) and redacted thinking (anthropic.redactedData) — while still replaying that same message's tool_use parts.
Anthropic requires a tool_use block to be preceded by its thinking/redacted_thinking block when thinking is enabled. Replaying tool_use without the reasoning block yields a 400 from the API.
Impact
Multi-turn thinking + tool-use conversations with Anthropic break after an interrupt or failure mid-step: the follow-up request replays the errored message's tool calls stripped of their reasoning blocks and the provider rejects it.
The errored-message guard is otherwise a deliberate design decision, so the fix should be deliberate too.
Possible directions
Relax the message.error === undefined guard in to-llm-message.ts so reasoning provider state is reused for errored messages when provider+model match, or
Drop the errored message's tool-call parts alongside the reasoning so the replayed message stays self-consistent (no orphaned tool_use).
Either way, the invariant to preserve is: never replay a tool_use part to Anthropic without its preceding thinking block while thinking is enabled.
Problem
In the V2 session core, replaying history that contains an errored assistant message can produce a request Anthropic rejects with a 400 when extended thinking is enabled.
reuseProviderMetadatarequiresmessage.error === undefined(packages/core/src/session/runner/to-llm-message.ts:114), so an aborted/failed step drops all reasoning state on replay — both signed thinking (anthropic.signature) and redacted thinking (anthropic.redactedData) — while still replaying that same message'stool_useparts.Anthropic requires a
tool_useblock to be preceded by itsthinking/redacted_thinkingblock when thinking is enabled. Replayingtool_usewithout the reasoning block yields a 400 from the API.Impact
Multi-turn thinking + tool-use conversations with Anthropic break after an interrupt or failure mid-step: the follow-up request replays the errored message's tool calls stripped of their reasoning blocks and the provider rejects it.
Scope
packages/ai). Signed thinking is affected identically.Possible directions
message.error === undefinedguard into-llm-message.tsso reasoning provider state is reused for errored messages when provider+model match, ortool-callparts alongside the reasoning so the replayed message stays self-consistent (no orphanedtool_use).Either way, the invariant to preserve is: never replay a
tool_usepart to Anthropic without its preceding thinking block while thinking is enabled.