Parallel calls to the same streaming tool leave an orphan task after live teardown
メンテナーはふだん 1 日以内に返信
@llalitkumarrr がすでに取り組んでいます。
2026年9月8日 から。
評価
この issue はまだ評価されていません。
説明
Required Information
Describe the Bug:
When one live model response contains multiple calls to the same async-generator tool, ADK starts each call concurrently but stores only one task under InvocationContext.active_streaming_tools[tool.name]. Each registration overwrites the previous task reference. As a result, run teardown and stop_streaming(function_name) can only cancel the last registered call; earlier calls continue writing to the live request queue after their agent run has ended.
The violated lifecycle invariant is that every background tool task started by a live agent run must remain tracked until it completes or the run tears it down.
Steps to Reproduce:
- Create an async-generator
FunctionToolthat yields once and then waits. - Build one live function-call event containing two calls to that tool with different call IDs/arguments.
- Pass the event through
handle_function_calls_live(). - Wait until both tool tasks have started.
- Call
SingleFlow()._stop_background_tool_tasks(invocation_context). - Inspect both tasks.
Expected Behavior:
Both calls are tracked and cancelled during live-run teardown.
Observed Behavior:
Only the task currently stored in active_streaming_tools[tool.name].task is cancelled. The other task remains pending. This reproduces consistently on current main (b0180620f4c2f4f4467a89c37a30f75bf849700b).
Environment Details:
- ADK Library Version: current
mainatb0180620 - Desktop OS: macOS
- Python Version: 3.10.20
Model Information:
- Are you using LiteLLM: No
- Which model is being used: N/A (unit-level live function-call event)
Additional Context
The overwrite occurs in _process_function_live_helper() when it assigns a newly created task to active_streaming_tools[tool.name].task. stop_background_tool_tasks() later enumerates one task per registry entry, so it has no reference to the earlier call. Non-blocking live tools avoid the same collision by including the function-call ID in their task key.
I intend to keep all concurrent tasks for a streaming tool tracked while preserving the existing name-based stop_streaming behavior, and add a regression test through the real live function-call path. I can send the focused fix and test within 24 hours.
Regression:
Not confirmed.
Logs:
assert all(task.done() for task in tasks)
E assert False
Minimal Reproduction Code:
await handle_function_calls_live(
invocation_context,
event_with_two_calls_to_monitor,
{monitor_tool.name: monitor_tool},
)
await both_started.wait()
await SingleFlow()._stop_background_tool_tasks(invocation_context)
assert all(task.done() for task in started_tasks) # fails: one is still pending
How often has this issue occurred?:
- Always (100%)
- 主要言語
- Python
- スター
- 21.6k
- フォーク
- 4k
- 平均マージ
- 12時間 6分
- マージ済み PR(30日)
- 4
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
google/adk-python のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
google/adk-python#7298 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
google/adk-python#7292 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
google/adk-python#7289 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
google/adk-python#7282 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
CredentialsManager should also extract scopes when populating auth schemes対応中かも @sanketpatil06 が 3 日前に担当しました。 オープンcore needs review
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
google/adk-python#7266 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
google/adk-python の issue をすべて見る
似ている issue
-
bug status/needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
prowler-cloud/prowler#12887 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area: desktop platform: macos priority: p3 status: ready type: enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
use-agent-os/agent-os#3484 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
open-telemetry/opentelemetry-python-contrib#5113 · コメント 2 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
-
external
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
langchain-ai/docs#6255 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信