fix: ignore stale function responses#766
Open
gustafvh wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request modifies the contents_processor to handle orphaned function response events by dropping them instead of returning an error. This change treats such events as stale (e.g., from retries or reconnections) to prevent failing the entire turn. Corresponding tests have been updated and expanded to verify this new behavior. I have no feedback to provide.
|
@mazas-google tagging you here |
Contributor
When the latest event is a function response whose IDs do not match any function-call event in session history (stale client retry, reconnect, session restart), drop only that trailing event and continue with the remaining valid history instead of hard-failing content construction. Fixes google#760
866f976 to
c8017fb
Compare
Contributor
|
Hi @kdroste-google @baptmont Could you please review this PR, since all test cases are passing successfully? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Link to Issue or Description of Change
Problem
rearrangeEventsForLatestFunctionResponsereturns an error when the latest event is a function response and no matching function-call event can be found in session history:That is appropriate for malformed history, but it also fires when a stale tool result is replayed after a retry, reconnect, or session restart. The dangling response could be safely ignored; failing the whole request prevents the next turn from continuing on otherwise valid history.
Solution
When the latest function-response event has no matching call in history, drop only that trailing event and continue with the remaining valid contents. Other validation errors, such as a response set partially matching the wrong call event, remain hard errors.
Testing Plan
go test ./internal/llminternalAlignment with adk-python
This is specific to ADK Go's content-history rearrangement path. The shared behavior goal is that stale client retries should not make otherwise valid session history unusable.