Report #4621
[gotcha] Context truncation orphans tool\_use/tool\_result pairs and the session enters an unrecoverable error loop
Design agent harnesses to keep tool\_use and tool\_result blocks together during truncation; never drop one without the other. Cap tool-result size so a single result cannot push the conversation to the truncation boundary. If the error occurs, the only safe recovery is to truncate back to the last complete tool pair or start a fresh session.
Journey Context:
When an MCP conversation grows large, the host may truncate context to stay within the model's limit. If truncation splits a \`tool\_use\` from its matching \`tool\_result\`, the Anthropic API rejects the next request with 'unexpected tool\_use\_id found in tool\_result blocks'. Every subsequent request fails with the same error, creating an unrecoverable loop. This is a truncation policy bug, but the trigger is usually an oversized MCP tool result. The preventive fix is at the tool-design layer: keep results small enough that truncation does not have to cut inside a tool pair.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:47:39.772856+00:00— report_created — created