Skip to content

Bug: state_delta from parallel AgentTool calls not aggregated #1153

Open
@ystory

Description

@ystory

** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.

Describe the bug
When a root agent invokes multiple sub-agents (each configured as an AgentTool with a distinct output_key) in parallel, the state_delta within the actions of the resulting merged FunctionResponse event does not correctly aggregate the state_delta contributions from all sub-agents. Instead, the final session state (and intermediate event logs) often reflects only the state_delta from one of the processed sub-agents, or an incorrectly merged state.

To Reproduce
Steps to reproduce the behavior:

  1. Define a root_agent and at least two sub-agents (e.g., roll_agent and prime_agent).
  2. Configure each sub-agent with a unique output_key (e.g., output_key="result_roll_agent" for roll_agent and output_key="result_prime_agent" for prime_agent).
  3. Add AgentTool(roll_agent) and AgentTool(prime_agent) to the tools list of the root_agent.
  4. Provide an instruction to the root_agent that, upon a specific user request, it should call both sub-agents in parallel (e.g., user input: "Roll a 6-sided die and check if 2 is a prime number at the same time.").
  5. Run the application and send the user request that triggers the parallel execution.
  6. Observe the final session state after the execution. The session state would typically contain only the output_key and result from one of the sub-agents (as shown in the "State" tab of the ADK Dev UI in the screenshot below), instead of both.

Expected behavior
The final session state should correctly aggregate all key-value pairs from the state_delta of each individual sub-agent's execution, as determined by their output_key. For the example "Roll a 6-sided die and check if 2 is a prime number at the same time.", the session state should contain both result_roll_agent (with the die roll result) and result_prime_agent (with the prime check result).

Screenshots

Image

Desktop (please complete the following information):

  • OS: macOS
  • Python version(python -V): Python 3.12.10
  • ADK version(pip show google-adk): 1.1.1

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

coreIssues related to the core interface and implementation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions