Colvin introduces GEPA, a genetic optimization library that improves strings such as prompts by recombining strong candidates from a Pareto frontier. He pairs it with Logfire managed variables, which can hold typed configuration such as instructions, models, and token limits.
Agent Optimization with Pydantic AI: GEPA, Evals, Feedback Loops
Speaker
Samuel Colvin, creator of Pydantic and head of Pydantic, explains agent optimization with GEPA, evals, feedback loops, and managed variables at AI Engineer.
The demo asks an agent to find political ancestors of UK MPs in Wikipedia pages, while excluding spouses, siblings, and other non-ancestors. Colvin compares model outputs with a golden dataset and favors deterministic checks where possible; the basic prompt scores about 85%, while a more detailed prompt reaches about 92%.
A proposer agent uses evaluation results to suggest new prompts, which are then tested and iterated. In the demo, GEPA reaches 96.7% accuracy, though its prompt is more verbose and can overfit to the available cases. Colvin says optimization is especially useful when private or otherwise unfamiliar data makes the right context important.
Colvin demonstrates changing a running web agent's instructions and model through Logfire variables, without a redeployment. Variables can hold a Pydantic model with multiple fields, and targeting can direct traffic to different values for experiments. The intended next step is to connect evals to automatic updates.
Colvin says explicit feedback buttons often get few clicks, and suggests using users' next actions as an implicit signal of answer quality. Annotations can help build a golden dataset, while sensitive deployments can record categorical ratings without storing raw inputs or outputs. He also stresses that defining what counts as correct is a central challenge.
Takeaways
- Start with a task-specific eval and a reference set before optimizing prompts.
- Use deterministic comparisons when a reliable expected answer is available.
- Keep separate training and evaluation cases to spot prompt overfitting.
- Treat model choice, cost, speed, and accuracy as joint optimization goals.
- Use managed configuration to experiment with prompts and models without redeploying.
Mentioned in this talk
Search inside this talk
What was claimed 10
- works atSamuel Colvin works at
Pydantic
runs the company“I'm Samuel from Pydantic”
0:01inFrom Stateless Nightmares to Durable AgentsYouTube Unverified3 sources· Talk
- feature
Pydantic: observability platform
observability platform“Pydantic Logfire, an observability platform.”
YouTube Unverified1 source· Talk
- feature
Pydantic: agent framework
agent framework“We have Pydantic AI, the agent framework”
YouTube Unverified1 source· Talk
- integrates with
Pydantic Logfire integrates with OpenTelemetry
“Logfire is fundamentally an observability platform under the hood: OpenTelemetry, logs, metrics, and traces.”
YouTube Unverified1 source· Talk
- feature
Pydantic Logfire: manages typed configuration without redeployment
manages typed configuration without redeployment“managed variables, one of our newer features”
YouTube Unverified1 source· Talk
- featureGEPA: Optimizes strings such as text prompts or JSON data
“Ultimately, it's an optimization library: it optimizes a string.”
YouTube Unverified1 source· Talk
- metric
Shopify: Reduced annual cost from $5 million to $73,000 while improving performance
“They brought the price down from $5 million a year to $73,000 a year and improved performance over time.”
YouTube Unverified1 source· Talk
- uses
Pydantic AI uses
GPT-4.1
for the GEPA proposer agent“We’ll use GPT-4.1 for speed.”
YouTube Unverified1 source· Talk








