From 6ea3b1aa73b2af16ca0490f6e770c158c222b43b Mon Sep 17 00:00:00 2001 From: Oleksii Sholik Date: Tue, 12 May 2026 12:30:54 +0300 Subject: [PATCH 1/2] Pending tool results in Anthropic API contract violation when runtime restarts --- packages/agents-runtime/src/timeline-context.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/agents-runtime/src/timeline-context.ts b/packages/agents-runtime/src/timeline-context.ts index 13d88452e5..c1c48b15db 100644 --- a/packages/agents-runtime/src/timeline-context.ts +++ b/packages/agents-runtime/src/timeline-context.ts @@ -153,6 +153,14 @@ export function defaultProjection( toolCallId: runItem.key, isError: runItem.status === `failed`, }) + } else { + // Tool was interrupted (crashed mid-execution) - synthesize error result + messages.push({ + role: `tool_result`, + content: `Tool execution was interrupted before completion (status: ${runItem.status})`, + toolCallId: runItem.key, + isError: true, + }) } } From 113584d1b2591f184f20dbebbd3f104f2207ab68 Mon Sep 17 00:00:00 2001 From: Oleksii Sholik Date: Tue, 12 May 2026 12:31:58 +0300 Subject: [PATCH 2/2] Add changeset for pending tool result fix Co-Authored-By: Claude Opus 4.7 (1M context) --- .changeset/fix-pending-tool-on-restart.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-pending-tool-on-restart.md diff --git a/.changeset/fix-pending-tool-on-restart.md b/.changeset/fix-pending-tool-on-restart.md new file mode 100644 index 0000000000..21576b868f --- /dev/null +++ b/.changeset/fix-pending-tool-on-restart.md @@ -0,0 +1,5 @@ +--- +'@electric-ax/agents-runtime': patch +--- + +Fix Anthropic API contract violation when an agent restart leaves a tool call without a result. The timeline projection now synthesizes a synthetic error tool_result for interrupted tool calls so every tool_use has a matching tool_result.