Skip to content

Commit bce9610

Browse files
authored
Merge pull request #59 from vstorm-co/feat/0.3.3
feat: add ACP protocol, framework improvements and bug fixes
2 parents 78fbc56 + f7726dc commit bce9610

112 files changed

Lines changed: 3294 additions & 628 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ from pydantic_ai_backends import create_console_toolset
206206
from pydantic_ai_todo import create_todo_toolset
207207

208208
agent = create_deep_agent(
209-
model="openai:gpt-4.1",
209+
model="anthropic:claude-sonnet-4-6",
210210
toolsets=[create_todo_toolset(), create_console_toolset()],
211211
)
212212
```
@@ -218,7 +218,7 @@ from pydantic_ai_shields import CostTracking
218218
from pydantic_deep.capabilities.hooks import HooksCapability, Hook, HookEvent
219219

220220
agent = create_deep_agent(
221-
model="openai:gpt-4.1",
221+
model="anthropic:claude-sonnet-4-6",
222222
capabilities=[
223223
CostTracking(cost_budget_usd=5.0),
224224
HooksCapability(hooks=[

CHANGELOG.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,49 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.3.3] - 2026-04-02
9+
10+
### Changed
11+
12+
- Default models changed: main agent `anthropic:claude-opus-4-6`, subagents `anthropic:claude-sonnet-4-6`, summarization `anthropic:claude-haiku-4-5-20251001`
13+
- Replaced `include_general_purpose_subagent` with `include_builtin_subagents` — adds a built-in "research" deep agent (filesystem + web + memory) instead of a plain pydantic-ai Agent
14+
- **Subagents are now deep agents by default** — all subagents (built-in and custom) are created via `create_deep_agent()` with filesystem, web, memory, eviction, and patch support. Custom subagents that don't specify `agent` or `agent_factory` automatically get the deep agent factory
15+
- Removed `skills` parameter from `create_deep_agent()` — pass pre-loaded skills via `SkillsToolset(skills=[...])` in the `toolsets` parameter instead
16+
- Removed `image_support` parameter from `create_deep_agent()` — image support is now always enabled (multimodal `read_file` for `.png`, `.jpg`, `.gif`, `.webp`)
17+
- Changed `include_memory` default from `False` to `True` — persistent agent memory is now enabled by default
18+
- Changed `max_nesting_depth` default from `0` to `1` — subagents can now spawn their own subagents by default
19+
- Simplified context file discovery to `AGENTS.md` and `SOUL.md` only (removed DEEP.md, AGENT.md, CLAUDE.md). Subagents see only `AGENTS.md`; `SOUL.md` is main-agent-only
20+
- Replaced `include_web` with separate `web_search` and `web_fetch` parameters (both default `True`) — allows independent control of WebSearch and WebFetch capabilities
21+
- Added `thinking` parameter (default `"high"`) — enables model thinking/reasoning via pydantic-ai `Thinking` capability. Supports `True`/`False`/`"minimal"`/`"low"`/`"medium"`/`"high"`/`"xhigh"`
22+
- Changed `eviction_token_limit` default from `None` to `20_000` — large tool outputs automatically saved to files
23+
- Changed `patch_tool_calls` default from `False` to `True` — orphaned tool calls fixed automatically
24+
- `BASE_PROMPT` is now always included in system prompt — `instructions` parameter appends to it instead of replacing it
25+
- Moved `model_settings` parameter next to `model` in `create_deep_agent()` signature
26+
27+
### Added
28+
29+
- 5 new hook events: `BEFORE_RUN`, `AFTER_RUN`, `RUN_ERROR`, `BEFORE_MODEL_REQUEST`, `AFTER_MODEL_REQUEST` — maps to pydantic-ai lifecycle hooks for session tracking, LLM call logging, and error alerts
30+
- `compact_conversation` tool — agent can manually trigger context compression with optional focus topic (uses `ContextManagerCapability.request_compact()`)
31+
- Anthropic prompt caching enabled by default (`anthropic_cache_instructions`, `anthropic_cache_tool_definitions`, `anthropic_cache_messages`) — silently ignored by non-Anthropic models
32+
- Built-in "research" subagent (`pydantic_deep/subagents.py`) — full deep agent for codebase exploration and web research
33+
- `upload_files()` batch method on `DeepAgentDeps` for uploading multiple files at once
34+
- `approve_tools` config in CLI — configure which tools require user approval (default: `["execute"]`). Set via `/config set approve_tools "execute,write_file,edit_file"` or in `config.toml`
35+
- Skills as slash commands in CLI — type `/code-review` to activate a skill directly from the picker
36+
- 3-tier skill discovery: built-in (`apps/cli/skills/`) → user (`~/.pydantic-deep/skills/`) → project (`.pydantic-deep/skills/`), with later sources overriding earlier by name
37+
- Provider setup wizard in CLI — first-run auto-detects missing API keys and guides through provider selection (Anthropic, OpenAI, Google, OpenRouter) with key input. Keys saved to `.pydantic-deep/.env`
38+
- `/provider` slash command — switch AI provider and model mid-session
39+
- `/config` slash command in CLI — view and change settings interactively (e.g., `/config set include_teams true`)
40+
- `web_search`, `web_fetch`, `thinking_effort`, and `include_teams` as configurable options in `config.toml`
41+
- ACP (Agent Client Protocol) adapter in `apps/acp/` — enables pydantic-deep agents to run inside editors like Zed. Streaming text deltas, tool call visibility with arguments and results, model switching, session management, auto-detect provider from API keys
42+
- Enhanced `BASE_PROMPT` with Claude Code-inspired sections: code quality, executing actions with care, tone and formatting
43+
- MCP documentation (`docs/advanced/mcp.md`) — shows how to use pydantic-ai's `MCP` capability with deep agents
44+
- Documentation for `BackendSkillsDirectory` in `docs/concepts/skills.md` — covers usage with `StateBackend`, `LocalBackend`, `DockerSandbox`, and mixed configurations
45+
- Cross-reference to backend-aware skills in `docs/concepts/backends.md`
46+
47+
### Fixed
48+
49+
- CLI bundled skills fallback path — was resolving to non-existent `apps/pydantic_deep/bundled_skills`, now correctly points to `apps/cli/skills/`
50+
851
## [0.3.2] - 2026-03-31
952

1053
### Added
@@ -103,7 +146,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
103146
### Fixed
104147

105148
- **`deps.todos` not synchronized with todo tools**`create_todo_toolset()` was called without `storage=` parameter, creating an isolated `TodoStorage` disconnected from `deps.todos`. Todo tools wrote to their own internal list while `deps.todos`, `get_todo_prompt()`, and `share_todos` remained empty. Fixed with `_DepsTodoProxy` pattern that delegates reads/writes to `deps.todos` at runtime. Subagent todo toolsets use the same proxy pattern for consistency. ([#35](https://github.com/vstorm-co/pydantic-deepagents/issues/35))
106-
- **`Model` objects discarded for subagents**`isinstance(model, str)` guard silently replaced `Model` objects (e.g. `TestModel()`, `AnthropicModel()`) with `DEFAULT_MODEL`. Subagents always used `openai:gpt-4.1` regardless of the model passed to `create_deep_agent()`. Changed to `model or DEFAULT_MODEL`. ([#34](https://github.com/vstorm-co/pydantic-deepagents/pull/34), by [@ret2libc](https://github.com/ret2libc))
149+
- **`Model` objects discarded for subagents**`isinstance(model, str)` guard silently replaced `Model` objects (e.g. `TestModel()`, `AnthropicModel()`) with `DEFAULT_MODEL`. Subagents always used `anthropic:claude-sonnet-4-6` regardless of the model passed to `create_deep_agent()`. Changed to `model or DEFAULT_MODEL`. ([#34](https://github.com/vstorm-co/pydantic-deepagents/pull/34), by [@ret2libc](https://github.com/ret2libc))
107150
- **Binary file upload tests flaky on Linux**`chardet` detected encoding for small byte sequences on Linux but not macOS, causing `line_count` assertions to fail in CI. Tests now mock `chardet.detect` for deterministic behavior.
108151

109152
### Changed
@@ -250,7 +293,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
250293
- Fixed `CLAUDE.md` - corrected `CompositeBackend` API signature (uses `default` and `routes`, not `backends`)
251294
- Fixed `README.md` - corrected import path `pydantic_deep.processors` to `pydantic_deep`
252295
- Fixed `docs/api/agent.md` - added missing `include_execute` parameter to signature and parameters table
253-
- Fixed `pydantic_deep/agent.py` - corrected docstring model default from "Claude Sonnet 4" to "openai:gpt-4.1"
296+
- Fixed `pydantic_deep/agent.py` - corrected docstring model default from "Claude Sonnet 4" to "anthropic:claude-sonnet-4-6"
254297

255298
## [0.2.13] - 2025-01-17
256299

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ from pydantic_ai_backends import create_console_toolset
206206
from pydantic_ai_todo import create_todo_toolset
207207

208208
agent = create_deep_agent(
209-
model="openai:gpt-4.1",
209+
model="anthropic:claude-sonnet-4-6",
210210
toolsets=[create_todo_toolset(), create_console_toolset()],
211211
)
212212
```
@@ -218,7 +218,7 @@ from pydantic_ai_shields import CostTracking
218218
from pydantic_deep.capabilities.hooks import HooksCapability, Hook, HookEvent
219219

220220
agent = create_deep_agent(
221-
model="openai:gpt-4.1",
221+
model="anthropic:claude-sonnet-4-6",
222222
capabilities=[
223223
CostTracking(cost_budget_usd=5.0),
224224
HooksCapability(hooks=[

README.md

Lines changed: 84 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ pydantic-deep implements the **deep agent pattern** -- the same architecture pow
5353
5454
---
5555

56-
**pydantic-deep** is three things:
56+
**pydantic-deep** is four things:
5757

5858
1. **A Python framework** for building Claude Code-style agents with planning, filesystem access, subagents, memory, and unlimited context
5959
2. **A CLI** that gives you a terminal AI assistant out of the box
60-
3. **DeepResearch** -- a full-featured research agent with web UI, web search, diagrams, and sandboxed code execution
60+
3. **An ACP adapter** that runs deep agents inside editors like Zed
61+
4. **DeepResearch** -- a full-featured research agent with web UI, web search, diagrams, and sandboxed code execution
6162

6263
---
6364

@@ -96,7 +97,7 @@ pydantic-deep run "Build a web scraper" --sandbox
9697
pydantic-deep chat --model anthropic:claude-sonnet-4-20250514
9798

9899
# Manage config
99-
pydantic-deep config set model openai:gpt-4.1
100+
pydantic-deep config set model anthropic:claude-sonnet-4-6
100101
```
101102

102103
> See [CLI docs](docs/cli/index.md) for the full reference.
@@ -125,15 +126,17 @@ One function call gives you an agent with planning, filesystem tools, subagents,
125126

126127
```python
127128
agent = create_deep_agent(
128-
model="openai:gpt-4.1",
129+
model="anthropic:claude-sonnet-4-6",
129130
include_todo=True, # Task planning
130131
include_filesystem=True, # File read/write/edit/execute
131132
include_subagents=True, # Delegate to subagents
132133
include_skills=True, # Domain-specific skills from SKILL.md files
133134
include_memory=True, # Persistent MEMORY.md across sessions
134135
include_plan=True, # Structured planning before execution
135136
include_teams=True, # Multi-agent teams with shared TODOs
136-
include_web=True, # Built-in WebSearch() and WebFetch() capabilities
137+
web_search=True, # WebSearch capability
138+
web_fetch=True, # WebFetch capability
139+
thinking="high", # Thinking/reasoning effort
137140
context_manager=True, # Auto-summarization for unlimited context
138141
cost_tracking=True, # Token/USD budget enforcement
139142
include_checkpoints=True, # Save, rewind, and fork conversations
@@ -192,25 +195,98 @@ agent = create_deep_agent(
192195
)
193196
```
194197

195-
### Custom Subagents
198+
### MCP Servers
199+
200+
Connect to any [MCP](https://modelcontextprotocol.io/) server via pydantic-ai's `MCP` capability:
201+
202+
```python
203+
from pydantic_ai.capabilities import MCP
204+
205+
agent = create_deep_agent(
206+
capabilities=[
207+
MCP(url="https://mcp.example.com/api"),
208+
],
209+
)
210+
```
211+
212+
### Subagents
213+
214+
A built-in **research** subagent is included by default. Add your own:
196215

197216
```python
198217
agent = create_deep_agent(
199218
subagents=[
200219
{
201220
"name": "code-reviewer",
202221
"description": "Reviews code for quality issues",
203-
"instructions": "You are a senior code reviewer...",
204-
"preferred_mode": "sync",
222+
"instructions": "Check for security, performance, error handling...",
205223
},
206224
],
207225
)
226+
# The main agent delegates: task(description="Review auth.py", subagent_type="code-reviewer")
227+
```
228+
229+
All subagents are full deep agents with filesystem, web, and memory tools. You only provide the specialized `instructions` — the framework adds `BASE_PROMPT` automatically.
230+
231+
### Project Files
232+
233+
pydantic-deep recognizes three special markdown files:
234+
235+
| File | Purpose | Who Sees It |
236+
|------|---------|-------------|
237+
| `AGENTS.md` | Project instructions, conventions, architecture | Main agent + subagents |
238+
| `SOUL.md` | Agent personality, style, user preferences | Main agent only |
239+
| `MEMORY.md` | Persistent memory across sessions (read/write/update tools) | Per-agent (isolated) |
240+
241+
```python
242+
agent = create_deep_agent(
243+
context_discovery=True, # Auto-discover AGENTS.md and SOUL.md at backend root
244+
include_memory=True, # MEMORY.md with read/write/update tools (on by default)
245+
)
208246
```
209247

248+
`AGENTS.md` follows the [agents.md spec](https://agents.md/) — compatible with other agent frameworks.
249+
210250
> See the full [API reference](https://vstorm-co.github.io/pydantic-deepagents/api/toolsets/) for all options.
211251
212252
---
213253

254+
## ACP -- Editor Integration (Zed)
255+
![zed.png](assets/zed.png)
256+
257+
Run pydantic-deep agents inside [Zed](https://zed.dev) via the [Agent Client Protocol](https://agentclientprotocol.com):
258+
259+
```bash
260+
pip install pydantic-deep[acp]
261+
python -m apps.acp
262+
```
263+
264+
Add to Zed settings (`Cmd+,`):
265+
266+
```json
267+
{
268+
"agent_servers": {
269+
"pydantic-deep": {
270+
"type": "custom",
271+
"command": "/path/to/venv/bin/python",
272+
"args": ["-m", "apps.acp"],
273+
"cwd": "/path/to/pydantic-deep"
274+
}
275+
}
276+
}
277+
```
278+
279+
API keys are loaded from `~/.pydantic-deep/.env` (global) or `.pydantic-deep/.env` (per-project):
280+
281+
```bash
282+
mkdir -p ~/.pydantic-deep
283+
echo 'OPENROUTER_API_KEY=sk-or-your-key' > ~/.pydantic-deep/.env
284+
```
285+
286+
> See [ACP README](apps/acp/README.md) for full configuration.
287+
288+
---
289+
214290
## DeepResearch -- Reference App
215291

216292
A full-featured research agent with web UI, built entirely on pydantic-deep.

apps/acp/README.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# ACP Adapter for pydantic-deep
2+
3+
[Agent Client Protocol (ACP)](https://agentclientprotocol.com) adapter that enables pydantic-deep agents to run inside editors like [Zed](https://zed.dev).
4+
5+
## Installation
6+
7+
```bash
8+
pip install pydantic-deep[acp]
9+
```
10+
11+
## Quick Start
12+
13+
```bash
14+
python -m apps.acp
15+
```
16+
17+
The server auto-detects your API key from environment variables or `.env` files and picks the right provider.
18+
19+
## API Key Setup
20+
21+
The ACP server looks for API keys in this order:
22+
23+
1. **Environment variables** (e.g., `ANTHROPIC_API_KEY`, `OPENROUTER_API_KEY`)
24+
2. **`~/.pydantic-deep/.env`** — global, all projects
25+
3. **`.pydantic-deep/.env`** — per-project
26+
4. **`.env`** — current directory
27+
28+
Create one:
29+
30+
```bash
31+
# Global (recommended)
32+
mkdir -p ~/.pydantic-deep
33+
echo 'OPENROUTER_API_KEY=sk-or-your-key' > ~/.pydantic-deep/.env
34+
35+
# Or per-project
36+
echo 'ANTHROPIC_API_KEY=sk-ant-your-key' > .pydantic-deep/.env
37+
```
38+
39+
The server auto-detects the provider from available keys:
40+
- `ANTHROPIC_API_KEY``anthropic:claude-sonnet-4-6`
41+
- `OPENROUTER_API_KEY``openrouter:anthropic/claude-sonnet-4`
42+
- `OPENAI_API_KEY``openai:gpt-4.1`
43+
- `GOOGLE_API_KEY``google:gemini-2.5-pro`
44+
45+
## Zed Configuration
46+
47+
Add to your Zed settings (`Cmd+,` → edit JSON):
48+
49+
```json
50+
{
51+
"agent_servers": {
52+
"pydantic-deep": {
53+
"type": "custom",
54+
"command": "/path/to/your/venv/bin/python",
55+
"args": ["-m", "apps.acp"],
56+
"cwd": "/path/to/pydantic-deep"
57+
}
58+
}
59+
}
60+
```
61+
62+
Find your Python path:
63+
64+
```bash
65+
# From the pydantic-deep directory
66+
echo "$(pwd)/.venv/bin/python"
67+
```
68+
69+
After saving, "pydantic-deep" appears in Zed's agent panel.
70+
71+
## Features
72+
73+
- Streaming text responses with real-time deltas
74+
- Tool call visibility with arguments (`read_file: /src/main.py`, `grep: TODO`)
75+
- Tool results displayed inline (file contents, search results, command output)
76+
- Model switching mid-session via Zed's model picker
77+
- Auto-detect provider from API keys
78+
- Session management with conversation history
79+
- Context file discovery (AGENTS.md, SOUL.md)
80+
- Full pydantic-deep toolset (filesystem, web, memory, skills, subagents)
81+
82+
## CLI Options
83+
84+
```bash
85+
python -m apps.acp # Auto-detect model
86+
python -m apps.acp --model anthropic:claude-opus-4-6 # Specific model
87+
python -m apps.acp --cwd /path/to/project # Working directory
88+
```
89+
90+
## Custom Agent Factory
91+
92+
```python
93+
from apps.acp.server import DeepAgentACP, AgentSessionContext
94+
from pydantic_deep import create_deep_agent
95+
96+
def build_agent(ctx: AgentSessionContext):
97+
return create_deep_agent(
98+
model=ctx.model,
99+
include_memory=True,
100+
context_discovery=True,
101+
thinking="high",
102+
)
103+
104+
server = DeepAgentACP(
105+
agent=build_agent,
106+
models=[
107+
{"value": "anthropic:claude-opus-4-6", "name": "Claude Opus 4.6"},
108+
{"value": "anthropic:claude-sonnet-4-6", "name": "Claude Sonnet 4.6"},
109+
],
110+
)
111+
```
112+
113+
## Architecture
114+
115+
```
116+
Editor (Zed)
117+
|
118+
| ACP protocol (stdio)
119+
| - text deltas
120+
| - tool call start/complete with content
121+
| - model switching
122+
|
123+
v
124+
DeepAgentACP (apps/acp/server.py)
125+
|
126+
| pydantic-ai Agent.iter() + node.stream()
127+
|
128+
v
129+
create_deep_agent() -- full deep agent with all tools
130+
```

apps/acp/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""ACP (Agent Client Protocol) adapter for pydantic-deep.
2+
3+
Bridges pydantic-deep agents with the Agent Client Protocol,
4+
enabling integration with editors like Zed.
5+
"""

0 commit comments

Comments
 (0)