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 分鐘
- 30 天內合併 PR
- 4
環境準備
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 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
-
難度 2/5 1-3 小時 新手友好度 72/100
-
bug
難度 1/5 1 小時以內 新手友好度 88/100
qgis/QGIS-Plugins-Website#459 ·
-
bug severity:medium
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 2 天內回覆
-
bot-found bug priority: P3
難度 2/5 1-3 小時 新手友好度 84/100
madenvel/KalinkaPlayer#179 ·
-
難度 2/5 1-3 小時 新手友好度 68/100
ls1intum/edutelligence#1098 ·
維護者通常 1 天內回覆