WhoBuilt

Agent Optimization with Pydantic AI: GEPA, Evals, Feedback Loops

May 7, 2026· 1 h 21 min· 10.0K views·Watch on YouTube

Speaker

Samuel Colvin, creator of Pydantic and head of Pydantic, explains agent optimization with GEPA, evals, feedback loops, and managed variables at AI Engineer.

GEPA and managed variables

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.

Build a task and measure it

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%.

Optimize prompts with GEPA

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.

Update agent behavior with managed variables

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.

Use feedback and choose meaningful evals

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

Show all 10 facts

Related talks