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:
- Use
@google/adk version 1.0.0.
- Configure an agent with any functional tool (e.g., a local math function or an MCP server).
- Send a prompt that triggers that tool.
- 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
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 acandidatesarray. The aggregator sees the empty array and returns early, causing thellm_agent.jsloop to detect an unexpected partial event and terminate the agent execution prematurely.To Reproduce
Steps to reproduce the behavior:
@google/adkversion 1.0.0."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 withpartial: falseand the complete accumulatedpartsSequence, even if the final chunk lacks acandidatesarray. This allows the agent loop to continue and execute the tool.Screenshots
N/A
Desktop (please complete the following information):