fix(live): stop retired streaming tools from writing into a new agent run

Đang mở
#8,302 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

@surajksharma07 đang làm issue này rồi.

Từ ngày 23/11/2026.

  • #8303 của @he-yufeng — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
ai, backend

Hướng nghiên cứu

Start with stop_background_tool_tasks() and _run_streaming_tool(), then trace how ActiveBackgroundTool registry entries relate to the shared LiveRequestQueue during Runner.run_live transfers. Reproduce with the mock Live connection. Done when a tool that ignores cancellation and yields after its entry is retired sends nothing to the model or user event path, and a late finally cannot remove a newer entry with the same function-call id. A linked pull request (#8303) already exists, so check it first.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Problem

stop_background_tool_tasks() gives a background tool one second to stop, then retires its registry entry even if the tool ignored cancellation. That best-effort lifecycle is useful, but retirement currently does not fence the tool's output path.

A streaming tool can swallow CancelledError, wait until its registry entry has been cleared, and then yield another result. _run_streaming_tool() still sends that result to the shared LiveRequestQueue. An Event yielded at the same point can still be enqueued as a user-facing message. During agent transfer, the old call can therefore write into the next agent's stream.

This is a remaining case after #7006. Ordinary cooperative cancellation stops the tool before the transfer delay; this report covers a tool that deliberately ignores the first cancellation and produces output only after retirement.

Reproduction

The regression uses the real Runner.run_live, an in-memory LiveRequestQueue, and the existing mock Live connection:

  1. The root agent starts a streaming tool and transfers to a subagent.
  2. The tool ignores its first cancellation.
  3. The shutdown timeout expires and the registry is cleared.
  4. The tool yields {"late": True} during the transfer delay.

On current main (2b90353cd2f1ee0a8a52262a7843333b6f7d2c8d), late_stream reaches the model connection after transfer. A second direct reproduction shows a retired tool yielding Event(message="stale") into the user event path.

Expected

Use the existing ActiveBackgroundTool entry as the call's ownership token. Once that exact entry is no longer registered, the call must stop producing model responses and user events. A late finally block must not remove a newer entry with the same function-call id. The existing one-second best-effort cancellation policy and normal output from a still-current tool should stay unchanged. No real Gemini Live endpoint is needed to verify the ADK-owned task, registry, and queue behavior.

Ngôn ngữ chính
Python
Star
22.3k
Fork
4.4k
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
6

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của google/adk-python

Tất cả issue của google/adk-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.