Skip to content

StreamingResponseAggregator fails to yield final non-partial event on tool calls, causing agent termination. #289

@TimKerre

Description

@TimKerre

Bug Report

Describe the bug
In StreamingResponseAggregator, the logic responsible for closing a stream fails to yield a final non-partial event when a tool call is made. This happens because the Gemini API often sends a final chunk without a candidates array. The aggregator sees the empty array and returns early, causing the llm_agent.js loop to detect an unexpected partial event and terminate the agent execution prematurely.

To Reproduce
Steps to reproduce the behavior:

  1. Use @google/adk version 1.0.0.
  2. Configure an agent with any functional tool (e.g., a local math function or an MCP server).
  3. Send a prompt that triggers that tool.
  4. The agent logs: "The last event is partial, which is not expected." and stops before executing the tool.

Expected behavior
The StreamingResponseAggregator.close() method should return a finalized event with partial: false and the complete accumulated partsSequence, even if the final chunk lacks a candidates array. This allows the agent loop to continue and execute the tool.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: [macOS]
  • TS version/environment: Node.js v22
  • ADK version: 1.0.0

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions