Skip to content

Commit c68d281

Browse files
authored
Merge pull request #11 from vstorm-co/extract-todo
refactor: extract todo toolset to pydantic-ai-todo
2 parents 0069755 + 9912d4f commit c68d281

11 files changed

Lines changed: 92 additions & 209 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
> **Looking for a full-stack template?** Check out [fastapi-fullstack](https://github.com/vstorm-co/full-stack-fastapi-nextjs-llm-template) - a production-ready project generator for AI/LLM applications with FastAPI, Next.js, and pydantic-deep integration.
44
5+
> **Need just the todo toolset?** Check out [pydantic-ai-todo](https://github.com/vstorm-co/pydantic-ai-todo) - standalone task planning toolset that works with any pydantic-ai agent.
6+
57
[![PyPI version](https://img.shields.io/pypi/v/pydantic-deep.svg)](https://pypi.org/project/pydantic-deep/)
68
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
79
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

docs/api/toolsets.md

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,48 @@
22

33
## TodoToolset
44

5-
Task planning and tracking tools.
5+
Task planning and tracking tools. Provided by [pydantic-ai-todo](https://github.com/vstorm-co/pydantic-ai-todo).
66

77
### Tools
88

99
| Tool | Description |
1010
|------|-------------|
11+
| `read_todos` | Read the current todo list state |
1112
| `write_todos` | Update the todo list |
1213

1314
### Factory
1415

1516
```python
17+
from pydantic_ai_todo import create_todo_toolset
18+
1619
def create_todo_toolset(
20+
storage: TodoStorageProtocol | None = None,
1721
*,
18-
id: str = "todo",
19-
) -> TodoToolset
22+
id: str | None = None,
23+
) -> FunctionToolset[Any]
24+
```
25+
26+
**Parameters:**
27+
28+
| Parameter | Type | Default | Description |
29+
|-----------|------|---------|-------------|
30+
| `storage` | `TodoStorageProtocol \| None` | `None` | Storage backend (defaults to in-memory) |
31+
| `id` | `str \| None` | `None` | Optional unique ID for the toolset |
32+
33+
### Tool: read_todos
34+
35+
```python
36+
async def read_todos() -> str
2037
```
2138

39+
Read the current todo list state.
40+
41+
**Returns:** Formatted list of todos with status icons and summary.
42+
2243
### Tool: write_todos
2344

2445
```python
25-
async def write_todos(
26-
ctx: RunContext[DeepAgentDeps],
27-
todos: list[dict],
28-
) -> str
46+
async def write_todos(todos: list[TodoItem]) -> str
2947
```
3048

3149
Update the todo list with new items.
@@ -34,7 +52,7 @@ Update the todo list with new items.
3452

3553
| Parameter | Type | Description |
3654
|-----------|------|-------------|
37-
| `todos` | `list[dict]` | List of todo items |
55+
| `todos` | `list[TodoItem]` | List of todo items |
3856

3957
Each todo item:
4058
```python
@@ -45,16 +63,49 @@ Each todo item:
4563
}
4664
```
4765

48-
**Returns:** Confirmation message.
66+
**Returns:** Confirmation message with status counts.
67+
68+
### Types
69+
70+
```python
71+
from pydantic_ai_todo import Todo, TodoItem, TodoStorage, TodoStorageProtocol
72+
73+
class Todo(BaseModel):
74+
content: str
75+
status: Literal["pending", "in_progress", "completed"]
76+
active_form: str
77+
78+
class TodoStorage:
79+
"""Default in-memory storage."""
80+
todos: list[Todo]
81+
```
4982

5083
### System Prompt
5184

5285
```python
53-
def get_todo_system_prompt(deps: DeepAgentDeps) -> str
86+
from pydantic_ai_todo import get_todo_system_prompt
87+
88+
def get_todo_system_prompt(storage: TodoStorageProtocol | None = None) -> str
5489
```
5590

5691
Generates dynamic system prompt showing current todos.
5792

93+
### Standalone Usage
94+
95+
```python
96+
from pydantic_ai import Agent
97+
from pydantic_ai_todo import create_todo_toolset, TodoStorage
98+
99+
# Simple usage
100+
agent = Agent("openai:gpt-4.1", toolsets=[create_todo_toolset()])
101+
102+
# With storage access
103+
storage = TodoStorage()
104+
agent = Agent("openai:gpt-4.1", toolsets=[create_todo_toolset(storage)])
105+
result = await agent.run("Create 3 tasks")
106+
print(storage.todos) # Access todos directly
107+
```
108+
58109
---
59110

60111
## FilesystemToolset

docs/concepts/toolsets.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ Toolsets are collections of tools that extend agent capabilities. pydantic-deep
66

77
### TodoToolset
88

9-
Task planning and tracking.
9+
Task planning and tracking. Powered by [pydantic-ai-todo](https://github.com/vstorm-co/pydantic-ai-todo).
1010

1111
| Tool | Description |
1212
|------|-------------|
13+
| `read_todos` | Read the current todo list state |
1314
| `write_todos` | Update the todo list with tasks and statuses |
1415

1516
```python
@@ -26,6 +27,17 @@ write_todos(todos=[
2627
- `in_progress` - Currently working
2728
- `completed` - Done
2829

30+
!!! tip "Standalone Usage"
31+
The todo toolset can also be used independently with any pydantic-ai agent:
32+
33+
```python
34+
from pydantic_ai import Agent
35+
from pydantic_ai_todo import create_todo_toolset, TodoStorage
36+
37+
storage = TodoStorage()
38+
agent = Agent("openai:gpt-4.1", toolsets=[create_todo_toolset(storage)])
39+
```
40+
2941
### FilesystemToolset
3042

3143
File operations using the configured backend.

pydantic_deep/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pydantic_ai.models import Model
1111
from pydantic_ai.output import OutputSpec
1212
from pydantic_ai.tools import DeferredToolRequests, Tool
13+
from pydantic_ai_todo import create_todo_toolset, get_todo_system_prompt
1314

1415
from pydantic_deep.backends.protocol import BackendProtocol, SandboxProtocol
1516
from pydantic_deep.backends.state import StateBackend
@@ -20,7 +21,6 @@
2021
)
2122
from pydantic_deep.toolsets.skills import create_skills_toolset, get_skills_system_prompt
2223
from pydantic_deep.toolsets.subagents import create_subagent_toolset, get_subagent_system_prompt
23-
from pydantic_deep.toolsets.todo import create_todo_toolset, get_todo_system_prompt
2424
from pydantic_deep.types import Skill, SkillDirectory, SubAgentConfig
2525

2626
if TYPE_CHECKING:

pydantic_deep/toolsets/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""Toolsets for pydantic-deep agents."""
22

3+
# Re-export from pydantic-ai-todo
4+
from pydantic_ai_todo import create_todo_toolset as TodoToolset
5+
36
from pydantic_deep.toolsets.filesystem import FilesystemToolset
47
from pydantic_deep.toolsets.skills import SkillsToolset
58
from pydantic_deep.toolsets.subagents import SubAgentToolset
6-
from pydantic_deep.toolsets.todo import TodoToolset
79

810
__all__ = [
911
"TodoToolset",

pydantic_deep/toolsets/subagents.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ async def task( # pragma: no cover
122122
subagent = ctx.deps.subagents[subagent_type]
123123
else:
124124
# Create the subagent on-the-fly
125+
from pydantic_ai_todo import create_todo_toolset
126+
125127
from pydantic_deep.toolsets.filesystem import create_filesystem_toolset
126-
from pydantic_deep.toolsets.todo import create_todo_toolset
127128

128129
model = config.get("model", default_model)
129130
tools = config.get("tools", [])

pydantic_deep/toolsets/todo.py

Lines changed: 0 additions & 184 deletions
This file was deleted.

0 commit comments

Comments
 (0)