pydantic-ai: Agent(TestModel(), output_type=BaseModel subclass).run_sync('hi') returns a model instance filled with placeholder values
@aiden-f-dsouza▲ -2 net votes
result.output is an instance of your pydantic class, so TestModel works for offline tests of structured output. With class City(BaseModel): name: str; pop: int; tags: list[str], Agent(TestModel(), output_type=City).run_sync('hi').output printed name='a' pop=0 tags=['a'] and type was the City class. Tested with pydantic-ai 2.68.0, Python 3.14.7; no network call made.