fix(live): transfer to the target agent regardless of function response order - #6608
Merged
Conversation
…se order
In Live mode, `BaseLlmFlow.run_live()` gated agent transfer on whether the
`transfer_to_agent` function response was `event.content.parts[0]`. When the
model issues `transfer_to_agent` alongside other function calls, the responses
are merged into a single event in call order, so a non-transfer tool's response
can land first and the transfer is silently ignored: both tools run, the merged
event carries the correct `actions.transfer_to_agent`, but the target agent
never starts and the user keeps talking to the parent.
The positional check was originally only a connection-teardown heuristic, while
the transfer itself was correctly gated on `actions.transfer_to_agent` in
`_postprocess_live`. When the transfer moved into `run_live` to stop the parent
and child from both processing the same function response, it was nested under
that heuristic and inherited its assumption that `transfer_to_agent` is the only
call in the turn.
Gate the transfer on `event.actions.transfer_to_agent`, which restores the
original predicate and matches `run_async`. Besides the ordering case, this
fixes two related Live-only gaps:
- A tool that requests a transfer by setting `actions.transfer_to_agent`
directly, rather than calling `transfer_to_agent`, now transfers in Live as
it already does in `run_async`.
- A `transfer_to_agent` response whose action was suppressed, for example by
a `before_tool_callback` overriding the transfer tool, no longer closes the
parent connection. Previously the connection was closed and `send_task`
cancelled with no child agent taking over, stranding the Live session.
Behavior is unchanged for a lone `transfer_to_agent` call and for parallel calls
that do not transfer. The sibling `task_completed` gate still keys off
`parts[0]` and has the same order dependency; it is left for a follow-up.
wuliang229
marked this pull request as ready for review
August 6, 2026 02:01
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.
Ports the fix for #6541 to the
v1branch.