Skip to content

LlmAgent(mode="task") with a raw dict output_schema fails at construction with SchemaError: Unknown schema type: "object" #7935

Description

@yifanxiong272

🔴 Required Information

Describe the Bug:
SchemaType documents raw dict schemas as supported for output_schema, and an LlmAgent with a dict output_schema builds in the default mode and in mode="single_turn". With mode="task", construction fails: FinishTaskTool builds TypeAdapter(self.output_schema), and pydantic reads the dict as one of its own core schemas, so {"type": "object", ...} raises SchemaError and {} raises KeyError: 'type'. A pydantic model or list[str] works.

Steps to Reproduce:

  1. pip install google-adk==2.13.0
  2. Run the script below.

Expected Behavior:
The task-mode agent builds, as it does with a pydantic model, and its finish tool validates against the JSON schema (or accepts the result without validation).

Observed Behavior:

pydantic_core._pydantic_core.SchemaError: Unknown schema type: "object"

Environment Details:

  • ADK Library Version (pip show google-adk): 2.13.0, and main at 95d8610
  • Desktop OS: Linux
  • Python Version (python -V): 3.12

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: none is called; the error is at construction

🟡 Optional Information

Minimal Reproduction Code:

from google.adk.agents import LlmAgent

schema = {"type": "object", "properties": {"answer": {"type": "string"}}}
print(LlmAgent(name="a", model="gemini-2.5-flash", output_schema=schema).output_schema)
LlmAgent(name="b", model="gemini-2.5-flash", output_schema=schema, mode="task")

Logs:

{'type': 'object', 'properties': {'answer': {'type': 'string'}}}
pydantic_core._pydantic_core.SchemaError: Unknown schema type: "object"

Additional Context:
The same kind of failure for a dict output_schema was fixed in SetModelResponseTool (#5469); agents/llm/task/_finish_task_tool.py still passes the dict to TypeAdapter.

How often has this issue occurred?:
Always (100%)

Activity

  1. mohitdixit02 commented on Nov 2, 2026

    @mohitdixit02

    Hi! I was able to reproduce this locally on ADK 2.13.0. In FinishTaskTool.__init__, self.output_schema is passed directly to TypeAdapter, which causes Pydantic to misinterpret a raw JSON schema dictionary as a core schema and fail with SchemaError.

    I'd like to work on this and submit a PR with regression tests, following the precedent established in SetModelResponseTool (#5516). Could you please assign this to me?

  2. added theissue type on Nov 5, 2026
  3. added
    core[Component] This issue is related to the core interface and implementation
    on Nov 5, 2026
  4. llalitkumarrr commented on Nov 5, 2026

    @llalitkumarrr
    Collaborator

    Hello @yifanxiong272,

    We were able to reproduce this issue, and we have also tested the linked PR which should resolve it. Could you please review the suggested changes and share your feedback?

  5. added
    request clarification[Status] The maintainer need clarification or more information from the author
    on Nov 5, 2026
  6. yifanxiong272 commented on Nov 5, 2026

    @yifanxiong272
    Author

    Thanks for reproducing and testing it. I reviewed the diff of #7937 against the report, and it fixes the case I reported: the task-mode agent now builds with a dict output_schema, the declaration carries the schema unchanged (deep-copied, so the caller's dict is not mutated), and accepting the result without validation matches how validate_node_data treats dict schemas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

core[Component] This issue is related to the core interface and implementationrequest clarification[Status] The maintainer need clarification or more information from the author

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions