fix: Don’t remove all events between last function response and function event that triggered it #2214
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the problem?
When long-running tools are mixed with normal tools, we get a situation where there are multiple tool responses in the event list for the same initial tool call event (multiple tool calls in one event, but individual events for each call following). There seems to be a filter rule in the ADK that expects there to be just one response for each call and it will find the last response for a call and remove all events in between. This makes no sense since shortly after, there is code to consolidate the multiple tool responses into a single event with all the responses. The path here is to just not call the function that removes some of the tool responses.
How did you accomplish this problem?
We removed the _rearrange_events_for_latest_function_response call from the _get_contents method to stop filtering interval responses from tool calls.