-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Orphaned function_call blocks from user interruption cause 400 errors #5856
Copy link
Copy link
Open
Labels
core[Component] This issue is related to the core interface and implementation[Component] This issue is related to the core interface and implementationrequest clarification[Status] The maintainer need clarification or more information from the author[Status] The maintainer need clarification or more information from the authorstale[Status] Issues which have been marked inactive since there is no user response[Status] Issues which have been marked inactive since there is no user response
Metadata
Metadata
Assignees
Labels
core[Component] This issue is related to the core interface and implementation[Component] This issue is related to the core interface and implementationrequest clarification[Status] The maintainer need clarification or more information from the author[Status] The maintainer need clarification or more information from the authorstale[Status] Issues which have been marked inactive since there is no user response[Status] Issues which have been marked inactive since there is no user response
Type
Fields
Give feedbackNo fields configured for Bug.
Description
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 atool_useevent with no matchingtool_result. Claude's API requires everytool_useto have a correspondingtool_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_responseblocks during context truncation. This issue is about orphanedfunction_callblocks caused by user interruption — a different problem that ADK does not currently handle.Current workaround
We use a
before_model_callbackthat scansllm_request.contentsand injects syntheticfunction_responsestubs for any unmatchedfunction_callblocks, preserving the rest of the conversation context.Expected behavior
ADK should handle orphaned
function_callblocks (from interruption or tool errors) gracefully, either by injecting synthetic responses or by stripping the orphaned calls before sending to the model API.