Skip to content

400 Error - when using agent as a tool with Root Agent #4391

@veevortexiq

Description

@veevortexiq

Bug Report: 400 INVALID_ARGUMENT in Nested Agent Calls

Environment:
Google ADK version: 1.18
Runtime: Cloud Run (us-central1)
Python: 3.12

Issue:
Nested agent calls fail with 400 INVALID_ARGUMENT error when parent agent invokes child agent as tool.

Stack Trace:
Error originates in child agent's generate_content_async call:

text
File "/usr/local/lib/python3.12/site-packages/google/adk/tools/agent_tool.py", line 160, in run_async
→ Child agent execution
File "/usr/local/lib/python3.12/site-packages/google/genai/models.py", line 7030, in generate_content
→ Gemini API call fails
google.genai.errors.ClientError: 400 INVALID_ARGUMENT

Configuration:

Child agent uses model="gemini-2.5-flash" or "gemini-2.5-pro"
Has tools=[ask_vertex_retrieval] defined
Uses before_model_callback guardrail
Has temperature=0.4, max_output_tokens=9000

Behavior:
✅ Works locally with same code
❌ Fails on Cloud Run deployment

Error message provides no details about which argument is invalid

Suspected Causes:

before_model_callback modifying request structure incorrectly for nested calls
Conflict between tools and output_schema in one agent (if applicable)
max_output_tokens=9000 exceeding model limits in production environment
Authentication/permission differences between local and Cloud Run service account

Reproduction:
Parent agent → calls child agent as tool → child agent calls Gemini API → 400 error

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