Skip to content

ValueError: "No function call event found" for function responses in 1.22.1 with SequentialAgent and AgentTool #4159

@kashirin-dm

Description

@kashirin-dm

Describe the bug
ValueError: No function call event found for function responses ids occurs in google-adk==1.22.1 when using a SequentialAgent wrapped in an AgentTool. This error signifies a mismatch/missing event in the conversation history, specifically when a sub-agent within the SequentialAgent completes a tool call. Downgrading to google-adk==1.21.0 resolves the issue.

To Reproduce

  1. Define a SequentialAgent that contains LlmAgent sub-agents.
  2. Wrap this SequentialAgent in an AgentTool and provide it to a parent LlmAgent.
  3. Invoke the parent agent such that it delegates to the AgentTool (the SequentialAgent).
  4. Inside the SequentialAgent, one of the sub-agents performs a tool call (e.g., using an MCP tool).
  5. Upon receiving the tool result, the framework fails with:
ValueError: No function call event found for function responses ids: {'adk-xxxx-xxxx-...'}

Stacktrace:

  File ".../google/adk/flows/llm_flows/contents.py", line 442, in _get_contents
    result_events = _rearrange_events_for_latest_function_response(
        filtered_events
    )
  File ".../google/adk/flows/llm_flows/contents.py", line 195, in _rearrange_events_for_latest_function_response
    raise ValueError(
        'No function call event found for function responses ids:'
        f' {function_responses_ids}'
    )
ValueError: No function call event found for function responses ids: {'adk-31549d8b-460a-428c-80ec-edd43bb8c30d'}

Expected behavior
The internal InMemorySessionService created by AgentTool should correctly persist and associate function_call events with their subsequent function_response events, allowing the SequentialAgent to continue execution without a ValueError.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: macOS (15.2)
  • Python version(python -V): 3.14.0 (also observed on 3.13)
  • ADK version(pip show google-adk): Broken in 1.22.1, works in 1.21.0.

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: gemini-3-flash-preview (also observed with others)

Additional context
The issue seems specific to the nested session logic in AgentTool. AgentTool creates a new InMemorySessionService for each call (agent_tool.py:155). In 1.22.1, it appears that either:

  1. The function_call event is not being correctly appended to the InMemorySession before the _get_contents logic is triggered for the response.
  2. The event filtering logic in contents.py (specifically _rearrange_events_for_latest_function_response) is filtering out the function_call due to branch mismatch or some other criteria introduced/changed in 1.22.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    core[Component] This issue is related to the core interface and implementation

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions