Skip to content

Commit 0e534e9

Browse files
committed
(draft) 0.2.14 release
1 parent 26edefc commit 0e534e9

22 files changed

Lines changed: 604 additions & 1233 deletions

CHANGELOG.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,47 @@ 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.2.14] - 2025-01-21
9+
10+
### Changed
11+
12+
- **Breaking:** Removed local `pydantic_deep/processors/` module - now uses external [summarization-pydantic-ai](https://github.com/vstorm-co/summarization-pydantic-ai) library
13+
- **Breaking:** Removed local `pydantic_deep/toolsets/subagents.py` module - now uses external [subagents-pydantic-ai](https://github.com/vstorm-co/subagents-pydantic-ai) library
14+
- Added `summarization-pydantic-ai>=0.0.1` dependency
15+
- Added `subagents-pydantic-ai>=0.0.1` dependency
16+
- Re-exported `SummarizationProcessor`, `SlidingWindowProcessor`, `create_summarization_processor`, `create_sliding_window_processor` from summarization-pydantic-ai
17+
- Re-exported `SubAgentToolset`, `create_subagent_toolset`, `get_subagent_system_prompt` from subagents-pydantic-ai
18+
- Re-exported `SubAgentConfig`, `CompiledSubAgent` types from subagents-pydantic-ai
19+
- Updated `DeepAgentDeps.clone_for_subagent()` to accept optional `max_depth` parameter for nested subagent support
20+
21+
### Added
22+
23+
- `SlidingWindowProcessor` - zero-cost message trimming without LLM calls (new from summarization-pydantic-ai)
24+
- `create_sliding_window_processor()` - factory function for sliding window processors
25+
- **Dual-mode execution**: Subagents can now run in sync (blocking) or async (background) modes
26+
- **Auto mode**: Intelligent mode selection based on task characteristics
27+
- **Task management tools**: `check_task`, `list_active_tasks`, `soft_cancel_task`, `hard_cancel_task`
28+
- **Subagent communication**: `ask_parent` tool for subagents to query the parent agent
29+
- **Dynamic agent creation**: Runtime agent creation via `create_agent_factory_toolset`
30+
- New types: `TaskHandle`, `TaskStatus`, `TaskPriority`, `TaskCharacteristics`, `ExecutionMode`
31+
32+
### Fixed
33+
34+
- Added `chardet>=5.0.0` dependency back - was incorrectly removed in 0.2.13 but is still needed for `DeepAgentDeps.upload_file()` encoding detection ([#22](https://github.com/vstorm-co/pydantic-deep/issues/22))
35+
- Subagents now automatically get `console_toolset` and `todo_toolset` like in previous versions - the migration to `subagents-pydantic-ai` accidentally removed these default tools ([#21](https://github.com/vstorm-co/pydantic-deep/issues/21))
36+
37+
### Documentation
38+
39+
- Updated `docs/advanced/processors.md` with SlidingWindowProcessor documentation
40+
- Updated `docs/api/processors.md` with full API reference for both processors
41+
- Updated `CLAUDE.md` with new processor imports and subagent imports from external packages
42+
- Updated `README.md` with subagents-pydantic-ai references in modular architecture
43+
- Updated `docs/advanced/subagents.md` with dual-mode execution and new SubAgentConfig fields
44+
- Updated `docs/api/toolsets.md` with complete SubAgentToolset API including task management tools
45+
- Updated `docs/api/types.md` with new subagent types (TaskHandle, TaskStatus, TaskPriority, ExecutionMode)
46+
- Updated `docs/examples/subagents.md` with correct tool names and updated SubAgentConfig example
47+
- Updated `docs/concepts/toolsets.md` with SubAgentToolset tools and correct parameter names
48+
849
## [0.2.13] - 2025-01-17
950

1051
### Changed

CLAUDE.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,21 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
4040
**Toolsets (`pydantic_deep/toolsets/`)**
4141
- `TodoToolset`: Task planning and tracking tools (read_todos, write_todos) - from [pydantic-ai-todo](https://github.com/vstorm-co/pydantic-ai-todo)
4242
- `create_console_toolset`: File operations (ls, read, write, edit, glob, grep, execute) - from [pydantic-ai-backend](https://github.com/vstorm-co/pydantic-ai-backend)
43-
- `SubAgentToolset`: Spawn and delegate to subagents
43+
- `SubAgentToolset`: Spawn and delegate to subagents - from [subagents-pydantic-ai](https://github.com/vstorm-co/subagents-pydantic-ai)
4444
- `SkillsToolset`: Load and use skill definitions from markdown files
4545

46-
**Processors (`pydantic_deep/processors/`)**
47-
- `SummarizationProcessor`: Automatic conversation summarization for token management
48-
- `create_summarization_processor()`: Factory function for creating summarization processors
46+
**Subagents (from [subagents-pydantic-ai](https://github.com/vstorm-co/subagents-pydantic-ai))**
47+
- `create_subagent_toolset()`: Factory function to create subagent toolsets
48+
- `get_subagent_system_prompt()`: Generate system prompt for subagent tools
49+
- Dual-mode execution: sync (blocking) or async (background)
50+
- Task management: check_task, list_active_tasks, soft_cancel_task, hard_cancel_task
51+
- Types: `SubAgentConfig`, `CompiledSubAgent`, `TaskHandle`, `TaskStatus`, `TaskPriority`
52+
53+
**Processors (from [summarization-pydantic-ai](https://github.com/vstorm-co/summarization-pydantic-ai))**
54+
- `SummarizationProcessor`: LLM-based conversation summarization for token management
55+
- `SlidingWindowProcessor`: Zero-cost message trimming without LLM calls
56+
- `create_summarization_processor()`: Factory function for summarization processors
57+
- `create_sliding_window_processor()`: Factory function for sliding window processors
4958

5059
**Types (`pydantic_deep/types.py`)**
5160
- Pydantic models for all data structures
@@ -107,15 +116,24 @@ agent = create_deep_agent(output_type=TaskResult)
107116

108117
**Context Management / Summarization**
109118
```python
110-
from pydantic_deep import create_deep_agent
111-
from pydantic_deep.processors import create_summarization_processor
119+
from pydantic_deep import (
120+
create_deep_agent,
121+
create_summarization_processor,
122+
create_sliding_window_processor,
123+
)
112124

113125
# Automatically summarize when reaching token limits
114126
processor = create_summarization_processor(
115127
trigger=("tokens", 100000), # or ("messages", 50) or ("fraction", 0.8)
116128
keep=("messages", 20), # Keep last N messages after summarization
117129
)
118130

131+
# Or use sliding window for zero-cost trimming
132+
window = create_sliding_window_processor(
133+
trigger=("messages", 100),
134+
keep=("messages", 50),
135+
)
136+
119137
agent = create_deep_agent(history_processors=[processor])
120138
```
121139

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
77
> **Need just the backends?** Check out [pydantic-ai-backend](https://github.com/vstorm-co/pydantic-ai-backend) - file storage and sandbox backends that work with any pydantic-ai agent.
88
9+
> **Need just subagents?** Check out [subagents-pydantic-ai](https://github.com/vstorm-co/subagents-pydantic-ai) - task delegation toolset with dual-mode execution (sync/async).
10+
911
[![PyPI version](https://img.shields.io/pypi/v/pydantic-deep.svg)](https://pypi.org/project/pydantic-deep/)
1012
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
1113
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
@@ -41,7 +43,8 @@ pydantic-deep is built with modular, reusable components:
4143
|-----------|---------|-------------|
4244
| **Backends** | [pydantic-ai-backend](https://github.com/vstorm-co/pydantic-ai-backend) | File storage and Docker sandbox |
4345
| **Todo Toolset** | [pydantic-ai-todo](https://github.com/vstorm-co/pydantic-ai-todo) | Task planning and tracking |
44-
| **Summarization** | Built-in | Automatic context management* |
46+
| **Subagents** | [subagents-pydantic-ai](https://github.com/vstorm-co/subagents-pydantic-ai) | Task delegation with dual-mode execution |
47+
| **Summarization** | [summarization-pydantic-ai](https://github.com/vstorm-co/summarization-pydantic-ai) | Automatic context management* |
4548

4649
*\*Note: Summarization will be added to pydantic-ai core in late January 2025 ([pydantic-ai#3780](https://github.com/pydantic/pydantic-ai/pull/3780)). We will migrate to use it once available.*
4750

@@ -168,6 +171,8 @@ agent = create_deep_agent(history_processors=[processor])
168171
- **[pydantic-ai](https://github.com/pydantic/pydantic-ai)** - The foundation: Agent framework by Pydantic
169172
- **[pydantic-ai-backend](https://github.com/vstorm-co/pydantic-ai-backend)** - File storage and sandbox backends (extracted from pydantic-deep)
170173
- **[pydantic-ai-todo](https://github.com/vstorm-co/pydantic-ai-todo)** - Task planning toolset (extracted from pydantic-deep)
174+
- **[subagents-pydantic-ai](https://github.com/vstorm-co/subagents-pydantic-ai)** - Task delegation toolset (extracted from pydantic-deep)
175+
- **[summarization-pydantic-ai](https://github.com/vstorm-co/summarization-pydantic-ai)** - Context summarization (extracted from pydantic-deep)
171176
- **[fastapi-fullstack](https://github.com/vstorm-co/full-stack-fastapi-nextjs-llm-template)** - Full-stack AI app template with pydantic-deep
172177

173178
## Development

docs/advanced/processors.md

Lines changed: 106 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# History Processors
22

3-
pydantic-deep supports history processors for managing conversation context. The most common use case is automatic summarization to handle long conversations without exceeding token limits.
3+
pydantic-deep supports history processors for managing conversation context. These processors are powered by [summarization-pydantic-ai](https://github.com/vstorm-co/summarization-pydantic-ai) and provide two strategies:
4+
5+
- **SummarizationProcessor** - Intelligent LLM-based summarization
6+
- **SlidingWindowProcessor** - Zero-cost message trimming
47

58
!!! info "Coming to pydantic-ai"
69
This feature will be added to pydantic-ai core in late January 2025 ([pydantic-ai#3780](https://github.com/pydantic/pydantic-ai/pull/3780)). Once available, we will migrate to use the upstream implementation. The API will remain compatible.
710

811
## Summarization Processor
912

10-
The `SummarizationProcessor` monitors conversation length and automatically summarizes older messages when thresholds are reached.
13+
The `SummarizationProcessor` monitors conversation length and automatically summarizes older messages when thresholds are reached. This provides intelligent compression that preserves important context.
1114

1215
### Basic Usage
1316

1417
```python
15-
from pydantic_deep import create_deep_agent
16-
from pydantic_deep.processors import create_summarization_processor
18+
from pydantic_deep import create_deep_agent, create_summarization_processor
1719

1820
# Create a summarization processor
1921
processor = create_summarization_processor(
@@ -32,6 +34,8 @@ agent = create_deep_agent(
3234
You can trigger summarization based on different criteria:
3335

3436
```python
37+
from pydantic_deep import create_summarization_processor
38+
3539
# Trigger when message count exceeds threshold
3640
processor = create_summarization_processor(
3741
trigger=("messages", 50),
@@ -62,6 +66,8 @@ processor = create_summarization_processor(
6266
Control how much context to keep after summarization:
6367

6468
```python
69+
from pydantic_deep import create_summarization_processor
70+
6571
# Keep last N messages
6672
processor = create_summarization_processor(
6773
trigger=("tokens", 100000),
@@ -87,7 +93,10 @@ processor = create_summarization_processor(
8793
By default, the processor uses a simple character-based estimation (~4 characters per token). For more accurate counting, provide a custom token counter:
8894

8995
```python
90-
def count_tokens(messages):
96+
from pydantic_ai.messages import ModelMessage
97+
from pydantic_deep import create_summarization_processor
98+
99+
def count_tokens(messages: list[ModelMessage]) -> int:
91100
"""Custom token counter using tiktoken or similar."""
92101
import tiktoken
93102
enc = tiktoken.get_encoding("cl100k_base")
@@ -110,6 +119,8 @@ processor = create_summarization_processor(
110119
Customize how the summarization is performed:
111120

112121
```python
122+
from pydantic_deep import create_summarization_processor
123+
113124
custom_prompt = """
114125
Extract the key information from this conversation.
115126
Focus on:
@@ -129,33 +140,110 @@ processor = create_summarization_processor(
129140
)
130141
```
131142

132-
## Using the Processor Class Directly
143+
## Sliding Window Processor
144+
145+
The `SlidingWindowProcessor` provides a zero-cost alternative that simply discards old messages without LLM calls. This is useful when you don't need to preserve historical context.
146+
147+
### Basic Usage
148+
149+
```python
150+
from pydantic_deep import create_deep_agent, create_sliding_window_processor
151+
152+
# Create a sliding window processor
153+
processor = create_sliding_window_processor(
154+
trigger=("messages", 100), # Trim when reaching 100 messages
155+
keep=("messages", 50), # Keep last 50 messages
156+
)
157+
158+
# Create agent with the processor
159+
agent = create_deep_agent(
160+
history_processors=[processor],
161+
)
162+
```
163+
164+
### When to Use Sliding Window
165+
166+
Choose `SlidingWindowProcessor` when:
167+
168+
- **Cost matters**: No LLM calls for processing
169+
- **Speed matters**: Instant trimming without API latency
170+
- **Recent context is sufficient**: Tasks don't need historical information
171+
- **Conversations are long**: High-volume chat applications
133172

134-
For more control, use `SummarizationProcessor` directly:
173+
Choose `SummarizationProcessor` when:
174+
175+
- **Context preservation matters**: Need to remember earlier decisions
176+
- **Tasks span multiple topics**: Important details scattered throughout
177+
- **Quality over speed**: Willing to trade latency for better context
178+
179+
### Configuration Examples
135180

136181
```python
137-
from pydantic_deep.processors import SummarizationProcessor
182+
from pydantic_deep import create_sliding_window_processor
138183

139-
processor = SummarizationProcessor(
184+
# Message-based window
185+
processor = create_sliding_window_processor(
186+
trigger=("messages", 100),
187+
keep=("messages", 50),
188+
)
189+
190+
# Token-based window
191+
processor = create_sliding_window_processor(
192+
trigger=("tokens", 100000),
193+
keep=("tokens", 50000),
194+
)
195+
196+
# Fraction-based window
197+
processor = create_sliding_window_processor(
198+
trigger=("fraction", 0.8),
199+
keep=("fraction", 0.4),
200+
max_input_tokens=200000,
201+
)
202+
```
203+
204+
## Using Processor Classes Directly
205+
206+
For more control, use the processor classes directly:
207+
208+
```python
209+
from pydantic_deep import SummarizationProcessor, SlidingWindowProcessor
210+
211+
# Summarization processor
212+
summarizer = SummarizationProcessor(
140213
model="openai:gpt-4.1",
141214
trigger=("tokens", 100000),
142215
keep=("messages", 20),
143216
max_input_tokens=None,
144217
trim_tokens_to_summarize=4000, # Limit summary input size
145218
)
219+
220+
# Sliding window processor
221+
window = SlidingWindowProcessor(
222+
trigger=("tokens", 100000),
223+
keep=("messages", 50),
224+
)
146225
```
147226

148227
## How It Works
149228

229+
### Summarization Processor
230+
150231
1. **Before each model call**, the processor checks if any trigger condition is met
151232
2. If triggered, it finds a safe cutoff point that doesn't split tool call/response pairs
152233
3. Older messages are summarized using a lightweight LLM call
153234
4. The summary replaces the old messages, preserving recent context
154235
5. The agent continues with the compressed history
155236

237+
### Sliding Window Processor
238+
239+
1. **Before each model call**, the processor checks if any trigger condition is met
240+
2. If triggered, it finds a safe cutoff point that doesn't split tool call/response pairs
241+
3. Older messages are discarded (no LLM call)
242+
4. The agent continues with only recent messages
243+
156244
### Tool Call Safety
157245

158-
The processor ensures tool calls and their responses stay together:
246+
Both processors ensure tool calls and their responses stay together:
159247

160248
```
161249
Messages: [User, AI+ToolCall, ToolResponse, User, AI+ToolCall, ToolResponse, User]
@@ -167,14 +255,17 @@ Messages: [User, AI+ToolCall, ToolResponse, User, AI+ToolCall, ToolResponse, Use
167255
You can chain multiple history processors:
168256

169257
```python
170-
from pydantic_deep import create_deep_agent
171-
from pydantic_deep.processors import create_summarization_processor
258+
from pydantic_deep import (
259+
create_deep_agent,
260+
create_summarization_processor,
261+
create_sliding_window_processor,
262+
)
172263

173264
# Multiple processors are applied in order
174265
agent = create_deep_agent(
175266
history_processors=[
176267
create_summarization_processor(trigger=("tokens", 100000)),
177-
# Add more processors as needed
268+
create_sliding_window_processor(trigger=("messages", 200)),
178269
],
179270
)
180271
```
@@ -189,6 +280,8 @@ agent = create_deep_agent(
189280

190281
4. **Use fraction-based triggers for portability**: When switching between models with different context limits
191282

283+
5. **Consider hybrid approaches**: Use summarization for important conversations and sliding window for casual chat
284+
192285
## Next Steps
193286

194287
- [Structured Output](structured-output.md) - Type-safe responses with Pydantic models

0 commit comments

Comments
 (0)