Skip to content

fix(live): keep streaming tool yields from completing turns#6009

Open
he-yufeng wants to merge 1 commit into
google:mainfrom
he-yufeng:fix/live-stream-turn-complete
Open

fix(live): keep streaming tool yields from completing turns#6009
he-yufeng wants to merge 1 commit into
google:mainfrom
he-yufeng:fix/live-stream-turn-complete

Conversation

@he-yufeng
Copy link
Copy Markdown
Contributor

Summary

Fixes #5947.

This threads a turn_complete flag through the live request path so streaming tool updates can be sent as intermediate model input instead of being treated as completed user turns.

The change keeps the existing default behavior for normal send_content() calls:

  • LiveRequestQueue.send_content() still defaults to turn_complete=True
  • async generator tool yields now send turn_complete=False
  • _send_to_model() forwards the flag to the live connection
  • intermediate yields are not appended to session history
  • Gemini only uses the Gemini 3.1 realtime text shortcut for completed turns

Tests

PYTHONPATH=src python -m pytest tests/unittests/agents/test_live_request_queue.py tests/unittests/models/test_gemini_llm_connection.py tests/unittests/flows/llm_flows/test_base_llm_flow_realtime.py tests/unittests/streaming/test_streaming.py::test_live_streaming_text_content_persisted_in_session tests/unittests/flows/llm_flows/test_base_llm_flow.py -q
python -m pyink --check src/google/adk/agents/live_request_queue.py src/google/adk/models/base_llm_connection.py src/google/adk/models/gemini_llm_connection.py src/google/adk/flows/llm_flows/base_llm_flow.py src/google/adk/flows/llm_flows/functions.py tests/unittests/agents/test_live_request_queue.py tests/unittests/models/test_gemini_llm_connection.py tests/unittests/flows/llm_flows/test_base_llm_flow_realtime.py tests/unittests/testing_utils.py tests/unittests/workflow/testing_utils.py
git diff --check

@adk-bot adk-bot added the live [Component] This issue is related to live, voice and video chat label Jun 8, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Jun 8, 2026

Response from ADK Triaging Agent

Hello @he-yufeng, thank you for creating this PR!

This PR is a bug fix. While you have included a testing section and associated it with an issue, could you please also provide logs or a screenshot/recording demonstrating the fix in action (i.e. showing that streaming tool yields do not complete turns)? This will help reviewers to understand and review your PR more efficiently.

Please refer to our Contribution Guidelines for more information. Thanks!

@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented Jun 8, 2026

I have completed a thorough, read-only analysis of Pull Request #6009.

I have verified the mandatory compliance gate: Google's Contributor License Agreement (CLA) is successfully signed and verified (status SUCCESS) for the contributor @he-yufeng.

I generated a premium PR Analysis Report matching your guidelines. The report has been saved to the workspace brain directory:
👉 analysis_results.md

Key Highlights & Recommendation:

  • Recommendation: (Approve & Merge)
  • Problem Solved: Directly fixes Issue #5947. In live bidirectional streams, async generator-based tools yielding intermediate updates would trigger generation interruptions and infinite invocation loops.
  • The Fix: Successfully threads a new turn_complete configuration flag across:
    • live_request_queue.py:LiveRequest
    • functions.py:run_tool_and_update_queue (sets turn_complete=False on generator updates)
    • base_llm_flow.py:_send_to_model (channels the flag and gates session logging)
    • base_llm_connection.py & gemini_llm_connection.py (maps it directly into the wire connection payload)
  • High Value: It stops redundant tool loops and session history pollution. The test coverage is exceptionally neat and covers the new behaviors without mocking any core framework state.

Summary of Completed Work

  1. Compliance Validation: Fetched and verified the PR metadata from GitHub. Checked the CLA validation workflow (cla/google is signed and active).
  2. Analysis: Parsed the complete, line-by-line diff of PR fix(live): keep streaming tool yields from completing turns #6009 and cross-referenced with local workspace files.
  3. Synthesis: Compiled an exhaustive overview of the change impact on the active workspace and style compliance, packaging the output as a Markdown artifact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

live [Component] This issue is related to live, voice and video chat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streaming tool yields in live mode cause model to re-invoke the tool in a loop

2 participants