Skip to content

Commit 5735879

Browse files
committed
fix(agents): detect thinking-block errors in ProviderHttpError.errorBody
The recovery predicate in shouldRecoverAnthropicThinkingError only traversed cause, error, rawError, errorMessage, and message fields. ProviderHttpError stores the raw Anthropic response on errorBody, which contains the specific thinking-block signature rejection text, while .message carries a generic user-facing string. Adding errorBody to the error graph traversal lets the recovery path detect the production error shape and fire the non-destructive repair (repairRejectedThinkingReplayInSessionManager) instead of rethrowing the HTTP 400 and bricking the session. Test: added errorBody case to the wrapAnthropicStreamWithRecovery parameterized test suite. Fixes #98308
1 parent 816038e commit 5735879

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎src/agents/embedded-agent-runner/thinking.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,18 @@ describe("wrapAnthropicStreamWithRecovery", () => {
746746
return root;
747747
},
748748
},
749+
{
750+
name: "ProviderHttpError errorBody",
751+
createError: () =>
752+
Object.assign(new Error(genericizedProviderError), {
753+
errorBody: JSON.stringify({
754+
error: {
755+
message: "messages.12.content.3: Invalid `signature` in `thinking` block",
756+
type: "invalid_request_error",
757+
},
758+
}),
759+
}),
760+
},
749761
])(
750762
"retries genericized request errors carrying provider detail in $name",
751763
async ({ createError }) => {

‎src/agents/embedded-agent-runner/thinking.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ function shouldRecoverAnthropicThinkingError(
546546
current.rawError,
547547
current.errorMessage,
548548
current.message,
549+
current.errorBody,
549550
]);
550551
for (const candidate of candidates) {
551552
if (

0 commit comments

Comments
 (0)