It would be great if the agent framework supported structured output by accepting a pydantic.BaseModel as a schema for the expected result.
Motivation
Right now, outputs are unstructured and require manual parsing. With structured output, I could define a schema upfront and let the agent handle formatting + parsing automatically.
Example
from pydantic import BaseModel
class AgentResponse(BaseModel):
success: bool
output: str | None
foo: str
bar: str
agent.set_output_schema(AgentResponse)
response = await agent.run()
assert isinstance(response, AgentResponse)
It would be great if the agent framework supported structured output by accepting a
pydantic.BaseModelas a schema for the expected result.Motivation
Right now, outputs are unstructured and require manual parsing. With structured output, I could define a schema upfront and let the agent handle formatting + parsing automatically.
Example