# Pydantic Deep Agents

> A self-hosted terminal coding assistant and the Pydantic AI framework behind it

- Category: AI Coding / Autonomous Coding Agents
- Language: Python
- Licence: MIT
- Repository: https://github.com/vstorm-co/pydantic-deepagents
- Website: https://vstorm-co.github.io/pydantic-deepagents/
- Canonical page: https://ai-tldr.dev/tools/pydantic-deepagents/

## In short

Pydantic Deep Agents (the `pydantic-deep` package) is two things in one repository from the Vstorm team: a self-hosted terminal AI assistant in the style of Claude Code, and the Python framework that powers it. It sits in the Autonomous Coding Agents category of the AI Coding tools and is open-source, written in Python and licensed MIT.

## Overview

Pydantic Deep Agents (the `pydantic-deep` package) is two things in one repository from the Vstorm team: a self-hosted terminal AI assistant in the style of Claude Code, and the Python framework that powers it. The assistant plans, edits files, runs shell commands, searches the web, remembers across sessions, spawns sub-agents and connects to MCP servers, on whichever tool-calling model you point it at — Anthropic, OpenAI, OpenRouter, Google Gemini, local Ollama models or any OpenAI-compatible endpoint.

The framework exposes the same harness behind one function call. `create_deep_agent()` hands a model a filesystem, a shell, task planning, persistent memory, sub-agents, sandboxed execution, MCP and automatic context summarisation, with each capability switched on by a flag. It is built natively on Pydantic AI's Capabilities API, so responses can be typed Pydantic models, and the README states the codebase is checked with Pyright and MyPy in strict mode.

Its headline feature is Live Run Forking: an in-flight run can split into several isolated branches, each on a copy-on-write filesystem overlay with its own steering message and dollar budget, and an AI judge, a test command or a vote picks the branch the run continues from. The repository also ships DeepResearch, a reference web app built on the framework that shows planning, parallel sub-agents and a workspace file browser.

## What it does

- Claude Code-style terminal UI with streaming tool calls, real diffs, tool approval dialogs and 25+ slash commands
- Works with any tool-calling model: Anthropic, OpenAI, OpenRouter, Google Gemini, Ollama or an OpenAI-compatible URL
- `create_deep_agent()` framework with planning, sub-agents, agent teams, skills, memory and checkpoints as toggles
- Live Run Forking: parallel copy-on-write branches merged by an AI judge, test results or a vote
- Docker sandbox with named workspaces, browser automation via Playwright, and MCP server support
- Lifecycle hooks with a default security preset, fallback models, and token and USD budget tracking

## Getting started

Pick the path you need from the README: run the terminal assistant, or install the library and build your own agent.

1. Install the terminal assistant

   On macOS and Linux the install script sets up uv and the CLI with no Python setup. On Windows or for a manual install use `pip install "pydantic-deep[cli]"`.

```bash
curl -fsSL https://raw.githubusercontent.com/vstorm-co/pydantic-deep/main/install.sh | bash
```

2. Set a key and start it

   Export a provider key and launch the TUI. Switch models with `/model` inside the TUI or with the config command.

```bash
export ANTHROPIC_API_KEY=sk-ant-...
pydantic-deep

# pick another model
pydantic-deep config set model openai:gpt-5.4
```

3. Run headless or in a sandbox

   The same CLI runs a task without the TUI for CI and scripts, or inside a Docker sandbox with your project mounted at /workspace.

```bash
pydantic-deep run "Fix the failing test in test_auth.py"
pydantic-deep run --task-file task.md --json

pydantic-deep tui --sandbox docker
pydantic-deep tui --workspace ml-env
```

4. Build your own agent with the framework

   Install the library and create an agent with one call; capabilities such as forking, sub-agents, memory and cost tracking are switched on by flags.

```bash
pip install pydantic-deep
```

5. Create and run a deep agent

   A minimal agent from the README, with a state backend for its files.

```python
from pydantic_ai_backends import StateBackend
from pydantic_deep import create_deep_agent, create_default_deps

agent = create_deep_agent(
    model="anthropic:claude-sonnet-4-6",
    include_todo=True,
    include_subagents=True,
    include_memory=True,
    cost_tracking=True,
)

deps = create_default_deps(StateBackend())
result = await agent.run("Build a REST API for user auth", deps=deps)
```

## When to use it

- Running a Claude Code-style coding assistant in the terminal on a model you choose, including local Ollama models
- Scripting coding tasks in CI with the headless `pydantic-deep run` command
- Building a custom research or coding agent in Python without rewiring planning, memory, sandboxing and sub-agents
- Trying several approaches to one change in parallel and letting tests or an AI judge pick the winner
