Skip to content

Commit 794dbaf

Browse files
committed
fix(agents): classify expired thinking signatures
1 parent e8628c6 commit 794dbaf

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/agents/embedded-agent-helpers.isbillingerrormessage.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,20 @@ describe("classifyProviderRuntimeFailureKind", () => {
15611561
).toBe("replay_invalid");
15621562
});
15631563

1564+
it("classifies expired Anthropic thinking signatures as replay invalid", () => {
1565+
expect(
1566+
classifyProviderRuntimeFailureKind(
1567+
'{"type":"error","error":{"type":"invalid_request_error","message":"messages.1.content.440: Invalid `signature` in `thinking` block"}}',
1568+
),
1569+
).toBe("replay_invalid");
1570+
expect(
1571+
classifyProviderRuntimeFailureKind(
1572+
"ValidationException: invalid signature on thinking block",
1573+
),
1574+
).toBe("replay_invalid");
1575+
expect(classifyProviderRuntimeFailureKind("Invalid signature")).not.toBe("replay_invalid");
1576+
});
1577+
15641578
it("splits ambiguous provider runtime failures instead of collapsing to unknown", () => {
15651579
expect(classifyProviderRuntimeFailureKind({})).toBe("empty_response");
15661580
expect(classifyProviderRuntimeFailureKind("Unknown error (no error details in response)")).toBe(

src/agents/embedded-agent-helpers/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ const DNS_ERROR_RE = /\benotfound\b|\beai_again\b|\bgetaddrinfo\b|\bno such host
353353
const INTERRUPTED_NETWORK_ERROR_RE =
354354
/\beconnrefused\b|\beconnreset\b|\beconnaborted\b|\benetreset\b|\behostunreach\b|\behostdown\b|\benetunreach\b|\bepipe\b|\bsocket hang up\b|\bconnection refused\b|\bconnection reset\b|\bconnection aborted\b|\bnetwork is unreachable\b|\bhost is unreachable\b|\bfetch failed\b|\bconnection error\b|\bnetwork request failed\b/i;
355355
const REPLAY_INVALID_RE =
356-
/\bprevious_response_id\b.*\b(?:invalid|unknown|not found|does not exist|expired|mismatch)\b|\btool_(?:use|call)\.(?:input|arguments)\b.*\b(?:missing|required)\b|\bincorrect role information\b|\broles must alternate\b|\binput item id does not belong to this connection\b/i;
356+
/\bprevious_response_id\b.*\b(?:invalid|unknown|not found|does not exist|expired|mismatch)\b|\btool_(?:use|call)\.(?:input|arguments)\b.*\b(?:missing|required)\b|\bincorrect role information\b|\broles must alternate\b|\binput item id does not belong to this connection\b|\binvalid\b.*\bsignature\b.*\bthinking\b|\bsignature\b.*\bthinking\s+block\b/i;
357357
const SANDBOX_BLOCKED_RE =
358358
/\bapproval is required\b|\bapproval timed out\b|\bapproval was denied\b|\bblocked by sandbox\b|\bsandbox\b.*\b(?:blocked|denied|forbidden|disabled|not allowed)\b|\bexec denied\s*\(/i;
359359
const NO_BODY_HTTP_WRAPPER_RE =

0 commit comments

Comments
 (0)