Skip to content

Feature Request: Structured Output via Pydantic Models #125

Description

@sleynsol

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bounty-officialThere is a bounty prize on this issue. If you solve it you can claim a cash prize.

    Type

    No type

    Projects

    Status
    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions