From the team behind this repo: AgenticOS, the Sovereign Agentic AI Layer. AI agents your whole team can use and improve: open source (Apache-2.0), self-hosted, built on Pydantic AI.
Open-source Claude Code β that you can also build on.
A self-hosted terminal AI assistant and the Python framework behind it.
Use it today, or ship your own agent in one function call. Any model. 100% type-safe. MIT.
Docs · PyPI · Forking · Why · CLI · Framework · Examples
--- **Pydantic Deep Agents is two things in one repo:** π₯οΈ **A terminal AI assistant** β a self-hosted, open-source alternative to Claude Code. Install it, point it at any model, and it plans, edits files, runs commands, searches the web, remembers across sessions, spawns sub-agents, and connects to MCP servers. Almost everything Claude Code does β on the model *you* choose. π **A Python framework** β the *exact same harness* behind a single function call. `create_deep_agent()` hands a model a filesystem, shell, planning, memory, sub-agents, sandboxed execution, MCP, and unlimited context. Build your own assistant, research agent, or coding tool without rewiring the plumbing every time. Both run on **[Pydantic AI](https://github.com/pydantic/pydantic-ai)**, work with **any model** (Claude, GPT, Gemini, local), and are **100% type-safe** and MIT-licensed β and they share one trick nothing else has: [**Live Run Forking**](#-live-run-forking--the-feature-no-one-else-has), splitting a single run into parallel branches an AI judge merges back together. ## Two ways to use it ### π₯οΈ 1. Use the assistant A Claude-Code-style TUI in your terminal, on **any** model β no Python setup (the script installs `uv` + the CLI for you): ```bash curl -fsSL https://raw.githubusercontent.com/vstorm-co/pydantic-deepagents/main/install.sh | bash pydantic-deep ``` > Windows / manual: `pip install "pydantic-deep[cli]"` ### π 2. Build your own One function call gives you a full deep agent: ```bash pip install pydantic-deep ``` ```python from pydantic_deep import create_deep_agent agent = create_deep_agent(model="anthropic:claude-sonnet-4-6") result = await agent.run("Build a REST API for auth") ``` --- ## β Live Run Forking β the feature no one else has Claude Code can't do this. Aider can't. LangGraph and CrewAI can't. **It's the reason to use pydantic-deep.** When an agent hits a fork in the road β "should I refactor this with a decorator or a context manager?" β most tools force one bet. Pydantic Deep Agents lets the run **branch**: ``` βββ branch A: "use a decorator" ββ tests: 8/8 β conf 0.71 agent.run("refactor auth") βββ¬ββΌββ branch B: "use a context manager" ββ tests: 6/8 β conf 0.42 (shared history) β βββ branch C: "extract a base class" ββ tests: 8/8 β conf 0.55 β ββββΊ βοΈ AI judge weighs quality + tests + consistency β adopts branch A, continues the run ``` Each branch is **fully isolated**: a copy-on-write filesystem overlay (reads fall through to the parent, writes stay local), its own steering message, and its own `budget_usd` cap. The coordinator resolves the fork with one of four acceptance modes β `manual`, `auto`, `auto_with_fallback` (default), or `vote` β and the winning branch's history is adopted as the parent run's continuation. **Framework β opt in with one flag:** ```python agent = create_deep_agent( model="anthropic:claude-sonnet-4-6", forking=True, # gives the agent: fork_run, inspect_branches, ) # merge_or_select, diff_branches, fork_cost, terminate_branch ``` **Or run a real test command against every branch and let exit codes decide the winner:** ```python from pydantic_deep import LiveForkCapability agent = create_deep_agent( forking=LiveForkCapability(test_command="pytest -q", test_timeout_s=120), ) # confidence = quality_spreadΒ·0.4 + test_pass_ratioΒ·0.4 + internal_consistencyΒ·0.2 ``` **CLI β fork an in-flight conversation, watch branches stream live, merge the best:** ``` /fork # split the current run into N parallel branches >>A try a decorator # steer branch A >>B use a contextmgr # steer branch B /merge # resolve β manual picker, AI judge, or vote ``` Live per-branch panels stream each approach side by side; a judge screen scores them; you accept, review the diff, or decline. Configure branch count, budgets, per-branch models, and merge strategy with `/fork-config`. > π Full reference: [docs/capabilities/live-fork.md](docs/capabilities/live-fork.md) --- ## π Why pydantic-deep? The only tool that is **a terminal assistant** *and* **a Python framework** *and* can **fork its own runs** β without giving up type safety or your choice of model. | | **Pydantic Deep** | Claude Code | Aider | LangGraph | CrewAI | |---|:---:|:---:|:---:|:---:|:---:| | Terminal TUI assistant | β | β | β | β | β | | Python framework / library | β | β | ~ | β | β | | **Live run forking + AI judge** | β | β | β | β | β | | Multi-agent swarm + message bus | β | ~ | β | β | β | | Any model / any provider | β | Anthropic | β | β | β | | Sandboxed Docker execution | β | β | ~ | DIY | DIY | | Persistent memory + skills | β | β | β | DIY | ~ | | Type-safe structured output | β | β | β | ~ | ~ | | MCP servers | β | β | β | ~ | ~ | | Self-hosted, open source | β MIT | β | β | β | β | β first-class Β· ~ partial / via extensions Β· β not available Β· DIY you wire it yourself. Comparison reflects each project as of 2026-06; corrections welcome via PR. --- ## What's New - **2026-06-01** **v0.3.24** β **Live Run Forking** β split an in-flight `agent.run()` into N parallel branches with copy-on-write isolation, per-branch budgets, a test-runner hook, and four merge modes (`manual` / `auto` / `auto_with_fallback` / `vote`). Opt in with `forking=True`. - **2026-06-01** **v0.3.23** β **MCP client support** (framework + CLI). Connect GitHub, Figma (OAuth), Context7, DeepWiki, or any custom server. Import servers straight from Claude Code. New interactive `/mcp` command. Plus a full CLI presentation pass: clipboard image paste, real `+/-` diffs, tool icons, turn summaries. - **2026-06-01** **v0.3.23** β **Automatic fallback-model retry** β `fallback_model=` wraps your primary in a `FallbackModel` chain; fires on API errors but never on auth errors. Plus a batteries-included **security hook preset** (`default_security_hook()`) and three new output styles (`markdown`, `json-only`, `bullet`). - **2026-04-22** **v0.3.17** β LiteParse document parsing (`include_liteparse=True`) β PDFs, DOCX, XLSX, PPTX, and images with optional OCR, all local. - **2026-04-10** **v0.3.5** β Headless runner (`pydantic-deep run`), Docker sandbox with named workspaces, browser automation via Playwright. > Full history: [CHANGELOG.md](CHANGELOG.md) --- ## The Agent Harness Pydantic Deep Agents is an **agent harness** β the complete infrastructure that wraps an LLM and makes it a functional autonomous agent. The model provides intelligence; the harness provides planning, tools, memory, sandboxed execution, unlimited context, and β uniquely β the ability to fork.| β Live run forking | Split a run into N isolated branches, each trying a different approach. AI judge or test results pick the winner. No other agent framework has this. |
| π§ Tool-calling | File read/write/edit, shell execution, glob, grep, web search, web fetch, browser automation β wired up and ready. |
| π€ Multi-agent / swarm | Spawn subagents for parallel workstreams. Shared TODO lists with claiming. Peer-to-peer message bus. Full team coordination. |
| π§ Persistent memory | MEMORY.md persists across sessions. Auto-injected into the system prompt. Each agent has isolated memory by default. |
| βΎοΈ Unlimited context | Auto-summarization when approaching the token budget. LLM-based or zero-cost sliding window. Never hits a context wall. |
| π³ Sandboxed execution | Docker sandbox with named workspaces. Installed packages persist between sessions. Project dir mounted at /workspace. |
| ποΈ Plan Mode | Dedicated planner subagent asks clarifying questions and structures the work before execution begins. Headless-compatible. |
| π Checkpoints | Save conversation state at any point. Rewind to any checkpoint. Fork sessions to explore alternative approaches. |
| π Skills system | Domain-specific knowledge loaded on demand from SKILL.md files. Built-in: code-review, refactor, test-writer, git-workflow, and more. |
| π Document parsing | Parse PDFs, DOCX, XLSX, PPTX, and images with optional OCR via LiteParse. Runs locally β no cloud services required. |
| π MCP | Connect any Model Context Protocol server β GitHub, Figma (OAuth), Context7, DeepWiki, or custom. Import straight from Claude Code. |
| β‘ Lifecycle hooks + security preset | Claude Code-style PRE/POST_TOOL_USE hooks. Shell or Python handlers. default_security_hook() blocks destructive commands out of the box. |
| π Structured output | Type-safe Pydantic model responses via output_type. No JSON parsing. No dict["key"]. Full IDE autocomplete. |
| π Fallback models | Primary model fails? fallback_model= hops to the next in the chain β on API errors, never on auth errors. |
| π Stuck loop detection | Detects repeated identical tool calls, A-B-A-B alternating patterns, and no-op calls. Warns the model or stops the run. |
| π° Cost tracking | Real-time token and USD cost tracking per run and cumulative. Hard budget limits with BudgetExceededError. |
| β¨ Self-improving | /improve analyzes past sessions and proposes updates to MEMORY.md, SOUL.md, and AGENTS.md. |
| π·οΈ 100% type-safe | Pyright strict + MyPy strict. 100% test coverage. Every public API is fully typed β safe to use in production. |