Pydantic AI Harness tutorial: coding and memory

Learn to add coding and memory capabilities to Pydantic AI, with a script-editing example and persistent user preferences in a .memories directory.

Player not loading? Watch on YouTube

This tutorial introduces Pydantic AI Harness, a separate library that adds capabilities to a Pydantic AI agent. The speaker installs it with uv, then attaches capability instances through the agent's capabilities parameter.

The first example uses Coder to modify script.py by adding print statements. The speaker compares this programmatic coding assistant behavior with Claude Code and Codex, while questioning how useful that particular application would be.

The tutorial distinguishes core capabilities, which expose functionality supplied by a model or provider API, from harness capabilities that add tools and logic around a model. It briefly covers browser control through Playwright, skills, conversation search, spending limits and step persistence.

The longer example combines Memory with FileStore and points it at a .memories directory. After the agent receives a favorite-food preference, the speaker shows a database file and a memory.md file. A separate dinner prompt then produces a pizza recommendation using that stored preference.

The speaker says memory can be configured per user and given guidance about what to retain. By default, the model selects what to remember: in this example, it saves the food preference but not the dinner question. The demonstration covers agent functionality rather than a local LLM deployment or offline setup.