Week 1 every agent handed back a plain string. What does that make you do every time you want two fields — like a name and an email — out of one response?
Parse the string yourself? Regex, split, try/except, hope the model formats consistently?
And it breaks the moment the model rephrases. This week you skip the parser entirely. You give PydanticAI a Pydantic model as result_type, and result.output is no longer a string — it is an instance of that class with typed fields. A call returns Contact(name="...", email="...") directly.
So I define the shape I want and the model fills it in?
Exactly the contract. Week 2 covers Pydantic models for multi-field extraction, Literal for constrained single values, list[str] for variable-length lists, and chaining a summarizer into a Literal-typed classifier.
result_type=Contact with a Pydantic modelresult_type=Literal["high","medium","low"] for enumsresult_type=list[str] for variable-length listsGoal: agents return the shape you asked for, not the shape the model felt like.
Create a free account to get started. Paid plans unlock all tracks.
Week 1 every agent handed back a plain string. What does that make you do every time you want two fields — like a name and an email — out of one response?
Parse the string yourself? Regex, split, try/except, hope the model formats consistently?
And it breaks the moment the model rephrases. This week you skip the parser entirely. You give PydanticAI a Pydantic model as result_type, and result.output is no longer a string — it is an instance of that class with typed fields. A call returns Contact(name="...", email="...") directly.
So I define the shape I want and the model fills it in?
Exactly the contract. Week 2 covers Pydantic models for multi-field extraction, Literal for constrained single values, list[str] for variable-length lists, and chaining a summarizer into a Literal-typed classifier.
result_type=Contact with a Pydantic modelresult_type=Literal["high","medium","low"] for enumsresult_type=list[str] for variable-length listsGoal: agents return the shape you asked for, not the shape the model felt like.