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
{{ message }}
Repository navigation
Orphaned function_call blocks from user interruption cause 400 errors #5856
When a user sends a new message while a tool call is still pending (or the tool errors without ADK emitting a function_response), the persisted session contains a tool_use event with no matching tool_result. Claude's API requires every tool_use to have a corresponding tool_result — without one, every subsequent turn returns a 400 error and the session is permanently broken.
Difference from existing fixes
This is distinct from the fixes in #3504 and #4027, which address orphaned function_response blocks during context truncation. This issue is about orphaned function_call blocks caused by user interruption — a different problem that ADK does not currently handle.
Current workaround
We use a before_model_callback that scans llm_request.contents and injects synthetic function_response stubs for any unmatched function_call blocks, preserving the rest of the conversation context.
Expected behavior
ADK should handle orphaned function_call blocks (from interruption or tool errors) gracefully, either by injecting synthetic responses or by stripping the orphaned calls before sending to the model API.
Could you please share a minimal reproducible code and the steps for reproduction? Also are you facing this issue with Claude only or is a similar problem observed with other models? Furthermore, if you are not already using the latest version, kindly try our most recent release and share your observations.
Turn 2: ERROR: BadRequestError: messages.4: `tool_use` ids were found
without `tool_result` blocks immediately after: orphan_001.
Session is permanently broken.
Thank you for sharing this detailed report.
As you noted, this behavior is due to Claude's strict implementation of tool use and tool results pairing. We recommend that the best approach right now is to use the callback feature, which it appears you are already doing.
Could you please let us know if callback solves this issue?
This issue has been automatically marked as stale because it has not had recent activity for 7 days after a maintainer requested clarification. It will be closed if no further activity occurs within 7 days.
Activity
llalitkumarrr commentedon May 27, 2026
Hello @seanxiong1989 ,
Could you please share a minimal reproducible code and the steps for reproduction? Also are you facing this issue with Claude only or is a similar problem observed with other models? Furthermore, if you are not already using the latest version, kindly try our most recent release and share your observations.
seanxiong1989 commentedon May 27, 2026
Hey @llalitkumarrr — reproduces on both 1.29.0 and 2.1.0. Claude-specific (Gemini doesn't enforce tool_use/tool_result pairing).
Repro (Claude on Vertex AI):
Output:
llalitkumarrr commentedon May 29, 2026
Hello @seanxiong1989 ,
Thank you for sharing this detailed report.
As you noted, this behavior is due to Claude's strict implementation of tool use and tool results pairing. We recommend that the best approach right now is to use the callback feature, which it appears you are already doing.
Could you please let us know if callback solves this issue?
adk-bot commentedon Jun 5, 2026
This issue has been automatically marked as stale because it has not had recent activity for 7 days after a maintainer requested clarification. It will be closed if no further activity occurs within 7 days.
adk-bot commentedon Jun 12, 2026
This has been automatically closed because it has been marked as stale for over 7 days.
fix(flows): prune orphaned function calls on interrupted turns