Skip to content

output_schema and tools cannot be used together in Agent configuration #1111

@AlejandroBlanco2001

Description

@AlejandroBlanco2001

Describe the bug

When creating agents, it is possible to specify both an output_schema and tools. However, the current documentation does not mention any restriction or limitation when using these two parameters together.

If both parameters are provided, a runtime error occurs. This is a known limitation: due to how output_schema is implemented, an agent cannot both enforce an output schema and call tools directly. The current expected workaround is to create a separate sub-agent responsible for calling the tool.

To Reproduce

Steps to reproduce the behavior:

  1. Create an agent with the following code:
Agent(
    name="task_planner",
    model=create_litellm_model(model_name, api_base),
    instruction=(
        "You are a task planner. Return a JSON object with title, steps (array), "
        "and estimated_time (integer). Return ONLY valid JSON, nothing else."
    ),
    tools=[dummy_tool],
    output_schema=TaskPlan,
    output_key="task_plan",
)

Expected behavior

  • A clear runtime error (or static type error) explaining that tools and output_schema cannot be used together.
  • Updated documentation with a more explicit and visible note in the parameter descriptions explaining this limitation.

Screenshots

See the mentioned issue

Versions

  • OS: macOS
  • ADK version: 1.21
  • Python version: 3.11

Additional context

See the following issue google/adk-python#3969 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions