Skip to content

400 Error - when using VertexAI Rag tool #2038

@veevortexiq

Description

@veevortexiq

Bug Report: 400 INVALID_ARGUMENT in Nested Agent Calls

Environment:
Google Genai : 1.57.0
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.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Request contains an invalid argument.', 'status': '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

    priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions