fix: track concurrent streaming tool calls - #7059
Open
CorgiBoyG wants to merge 1 commit into
Open
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
CorgiBoyG
force-pushed
the
fix/streaming-tool-task-tracking
branch
from
September 8, 2026 10:26
4f68ffe to
33602a5
Compare
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.
Summary
LiveRequestQueueand broadcast live input to all active call streamsstop_streamingand live-run teardown while preserving later registrationsFixes #7058
Problem
_process_function_live_helper()stored one task per tool name inInvocationContext.active_streaming_tools. If a live model response invoked the same async-generator tool more than once, each registration replaced the previous task reference. The earlier call kept running but was no longer reachable bystop_streaming()or run teardown, so it could continue writing responses after its agent run ended. Input-streaming calls also shared or replaced the single stream slot.This violated the lifecycle invariant that every background tool call started by a live run remains tracked until it completes or the run stops it.
Solution
ActiveStreamingToolnow maintains a private task-to-stream registry while preserving its existingtaskandstreamcompatibility fields. Each call gets an independent input queue. Completion callbacks release task and stream references,stop_streamingoperates on a snapshot so it cannot remove calls registered later, and run teardown enumerates every active task.Testing
handle_function_calls_live()with two same-name calls and distinct input streams. It fails onmainbecause one task remains pending after teardown.stop_streamingcancellation paths.206 passedacross the complete streaming suite and directly related flow/tool tests.13,971 passed,85 skipped,27 xfailed,2 xpassedin the full unit suite. Two import-loading tests fail identically on unchangedmainbecause this host Python preloadssitecustomize; the same two tests were rerun againstupstream/mainto confirm the baseline.PYTHONASYNCIODEBUG=1.update-constraints, which was stopped after more than 18 minutes without output; this change does not modify dependencies or constraint files.function_tool.pyreproduces unchanged onupstream/main.Risk
The change is limited to live async-generator tool bookkeeping and input-stream injection. Existing name-based
stop_streamingbehavior remains intact: it stops all active calls for that tool name. Empty registry placeholders and the public compatibility fields retain their existing observable behavior, while completed tasks and streams are released.