fix(adk): resolve multi-turn conversation failure with None user_message #770
+8
−1
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.
Summary
adk_agent.pythat caused multi-turn conversations to fail withValueError: Both invocation_id and new_message are Noneerror on the second messageProblem
When using CopilotKit with ag-ui-adk, multi-turn conversations fail on the second message. The first message works correctly, but subsequent messages throw the error from Google ADK.
Root Cause
Two bugs combine to cause this issue:
Bug 1: Incorrect conditional (line 1080)
The condition
if message_batch else Noneincorrectly setsuser_messagetoNonewhenmessage_batchwas not explicitly passed (which is the normal case for direct calls via therunmethod), even whenunseen_messagescontained valid user messages.Bug 2: No fallback when unseen_messages is empty (line ~1187)
When
unseen_messagesis empty (because all messages were already marked as "processed" by ID), there was no fallback to extract the latest user message frominput.messages. This happens when:_get_unseen_messages()returns emptySolution
_convert_latest_messageis always called when there are unseen messagesinput.messageswhenuser_messageisNoneTest Plan
Fixes #769