Skip to content

Downsides to passing dataclasses.dataclass to Agent.output_type? #3234

@patrickkidd

Description

@patrickkidd

Question

I need a common data model defined in a way that can be shared between two apps: a web app that uses pydantic_ai, and a desktop app that cannot include heavy non-pure python dependencies like pydantic/pydantic_ai in its exe. All I want is to ensure that pydantic_ai enforces the output JSON to be valid against my schema, which includes an object hierarchy including lists and some enums (enums can be worked around if necessary). What are the downsides to just passing a dataclasses.dataclass to Agent? Is it going to be a fragile approach?

Additional Context

python 11.6, latest pydantic_ai

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions