Skip to content

[Feature Request] Preserve field descriptions in set_model_response tool schema #6707

Description

@jinnymoon1124

Is your feature request related to a specific problem?

Yes.

When using a Pydantic BaseModel as an output_schema, field descriptions defined with Field(description=...) are not preserved when ADK converts the output schema into the internal set_model_response tool.
https://github.com/google/adk-python/blob/main/src/google/adk/tools/set_model_response_tool.py

For example:

from pydantic import BaseModel, Field

class Output(BaseModel):
    answer: str = Field(
        description="The final answer to the user's question."
    )
    confidence: float = Field(
        description="Confidence score between 0 and 1."
    )

The descriptions are correctly included in:

Output.model_json_schema()

However, the generated set_model_response tool schema does not include these descriptions.

This means that semantic information explicitly provided in the output schema is lost before the schema is sent to the model.

Describe the Solution You'd Like

I would like set_model_response to preserve the field metadata from the original output_schema, especially Field(description=...).

For the example above, the generated tool schema should retain the descriptions:

{
  "properties": {
    "answer": {
      "type": "string",
      "description": "The final answer to the user's question."
    },
    "confidence": {
      "type": "number",
      "description": "Confidence score between 0 and 1."
    }
  }
}

More generally, it would be preferable for the generated set_model_response schema to preserve the relevant JSON Schema metadata from the original Pydantic model rather than reconstructing the fields using only their annotations and default values.

Impact on your work

We use output_schema to provide structured responses with field-level semantic instructions.

Field descriptions are important because field names and types alone are sometimes insufficient to communicate the intended meaning or constraints to the model.

Currently, we have to duplicate this information in the agent instructions because the descriptions are not available in the set_model_response tool schema.

Preserving the descriptions would make output_schema more useful as the single source of truth for structured output definitions and would reduce duplicated instructions.

There is no specific deadline for this feature.

Willingness to contribute

Yes. I would be interested in implementing this feature and submitting a PR if the maintainers agree on the preferred approach.


🟡 Recommended Information

Describe Alternatives You've Considered

I considered duplicating the field descriptions in the agent instructions, but this requires maintaining the same information in two places and can lead to inconsistencies.

Proposed API / Implementation

No new public API may be necessary. The existing Pydantic JSON schema could potentially be reused when creating the set_model_response function declaration so that field metadata such as description is preserved.

Additional Context

ADK has been really useful. Thanks a lot for your work!

Metadata

Metadata

Assignees

Labels

needs review[Status] The PR/issue is awaiting review from the maintainertools[Component] This issue is related to tools

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions