summarize_and_classify from yesterday returns a single string. A reviewer comment needs more than a scope label — it needs a category (major/minor revision, clarification), an urgency level, and a one-line task summary for your task list. How do you extract all three in one call?
Define a Pydantic model with three fields — category, urgency, and one_line_summary — and pass it as result_type. The model fills in each field exactly, like a structured extraction form.
Exactly. One Pydantic model, three fields, one agent call:
from pydantic import BaseModel
class Ticket(BaseModel):
category: str
urgency: str
one_line_summary: str
result = Agent(model, result_type=Ticket).run_sync(text)
return result.output.model_dump()Can I constrain urgency to high/medium/low inside the Pydantic model, or does that require a separate Literal agent?
Pydantic supports Literal as a field type: urgency: Literal["high", "medium", "low"]. The model must fill in that field with one of those three values — the same guarantee as result_type=Literal[...], but scoped to one field of a larger schema. That's the production pattern for multi-field extraction with constrained values.
So I could have category: Literal["major","minor","clarification"] and urgency: Literal["high","medium","low"] in the same model. Three constrained fields, one call, zero manual triage.
That's the full codebook-compliant extraction form. Every reviewer comment becomes a structured task in your management system.
Forty-page revision request → structured task list in seconds. This is the Reviewer 2 nightmare solved with a Pydantic model.
Each field is immediately useful:
ticket = triage_ticket(review_text)
print(ticket["category"], ticket["urgency"])
print(ticket["one_line_summary"])The model extracts. Your research judgment determines priority and response.
from pydantic import BaseModel
class Ticket(BaseModel):
category: str
urgency: str
one_line_summary: str
result = Agent(model, result_type=Ticket).run_sync(text)
return result.output.model_dump()Add Literal as a field type for guaranteed values:
from typing import Literal
class Ticket(BaseModel):
category: Literal["major", "minor", "clarification"]
urgency: Literal["high", "medium", "low"]
one_line_summary: strFor production triage, use Literal field types in the Pydantic model:
from typing import Literal
class Ticket(BaseModel):
category: Literal["major", "minor", "clarification"]
urgency: Literal["high", "medium", "low"]
one_line_summary: strThis gives per-field guarantees without separate Literal agents.
summarize_and_classify from yesterday returns a single string. A reviewer comment needs more than a scope label — it needs a category (major/minor revision, clarification), an urgency level, and a one-line task summary for your task list. How do you extract all three in one call?
Define a Pydantic model with three fields — category, urgency, and one_line_summary — and pass it as result_type. The model fills in each field exactly, like a structured extraction form.
Exactly. One Pydantic model, three fields, one agent call:
from pydantic import BaseModel
class Ticket(BaseModel):
category: str
urgency: str
one_line_summary: str
result = Agent(model, result_type=Ticket).run_sync(text)
return result.output.model_dump()Can I constrain urgency to high/medium/low inside the Pydantic model, or does that require a separate Literal agent?
Pydantic supports Literal as a field type: urgency: Literal["high", "medium", "low"]. The model must fill in that field with one of those three values — the same guarantee as result_type=Literal[...], but scoped to one field of a larger schema. That's the production pattern for multi-field extraction with constrained values.
So I could have category: Literal["major","minor","clarification"] and urgency: Literal["high","medium","low"] in the same model. Three constrained fields, one call, zero manual triage.
That's the full codebook-compliant extraction form. Every reviewer comment becomes a structured task in your management system.
Forty-page revision request → structured task list in seconds. This is the Reviewer 2 nightmare solved with a Pydantic model.
Each field is immediately useful:
ticket = triage_ticket(review_text)
print(ticket["category"], ticket["urgency"])
print(ticket["one_line_summary"])The model extracts. Your research judgment determines priority and response.
from pydantic import BaseModel
class Ticket(BaseModel):
category: str
urgency: str
one_line_summary: str
result = Agent(model, result_type=Ticket).run_sync(text)
return result.output.model_dump()Add Literal as a field type for guaranteed values:
from typing import Literal
class Ticket(BaseModel):
category: Literal["major", "minor", "clarification"]
urgency: Literal["high", "medium", "low"]
one_line_summary: strFor production triage, use Literal field types in the Pydantic model:
from typing import Literal
class Ticket(BaseModel):
category: Literal["major", "minor", "clarification"]
urgency: Literal["high", "medium", "low"]
one_line_summary: strThis gives per-field guarantees without separate Literal agents.
Create a free account to get started. Paid plans unlock all tracks.