Todo/task planning toolset for pydantic-ai agents
Project description
Todo Toolset for Pydantic AI
Task Planning and Tracking for AI Agents
Capabilities API — plug-and-play with one line • Subtasks & Dependencies — hierarchical task management • PostgreSQL Storage — persistent multi-tenant tasks • Event System — webhooks and callbacks
Todo Toolset for Pydantic AI adds task planning capabilities to any Pydantic AI agent. Your agent can create, track, and complete tasks with full support for subtasks, dependencies, and persistent storage.
Full framework? Check out Pydantic Deep Agents — complete agent framework with planning, filesystem, subagents, and skills.
Quick Start
The recommended way to add todo support is via the Capabilities API — one import, one line:
from pydantic_ai import Agent
from pydantic_ai_todo import TodoCapability
agent = Agent("openai:gpt-4.1", capabilities=[TodoCapability()])
result = await agent.run("Create a todo list for building a REST API")
TodoCapability automatically:
- Registers all todo tools (
add_todo,read_todos,write_todos,update_todo_status,remove_todo) - Injects dynamic system prompt showing current task state
- Creates in-memory storage (or use your own)
With Storage Access
from pydantic_ai_todo import TodoCapability, TodoStorage
storage = TodoStorage()
agent = Agent("openai:gpt-4.1", capabilities=[TodoCapability(storage=storage)])
result = await agent.run("Plan a blog application")
# Access todos directly
for todo in storage.todos:
print(f"[{todo.status}] {todo.content}")
With Subtasks and Dependencies
agent = Agent(
"openai:gpt-4.1",
capabilities=[TodoCapability(enable_subtasks=True)],
)
Enables add_subtask, set_dependency, and get_available_tasks tools with automatic cycle detection.
YAML Agent Definition
model: openai:gpt-4.1
instructions: "You are a project planner."
capabilities:
- TodoCapability:
enable_subtasks: true
agent = Agent.from_file("agent.yaml")
Installation
pip install pydantic-ai-todo
Or with uv:
uv add pydantic-ai-todo
Alternative: Toolset API
If you prefer the lower-level toolset approach (without capabilities):
from pydantic_ai import Agent
from pydantic_ai_todo import create_todo_toolset, get_todo_system_prompt, TodoStorage
storage = TodoStorage()
toolset = create_todo_toolset(storage=storage)
agent = Agent(
"openai:gpt-4.1",
toolsets=[toolset],
system_prompt=get_todo_system_prompt(storage),
)
Note: With the toolset API, you need to wire
get_todo_system_prompt()manually.TodoCapabilityhandles this automatically.
Available Tools
| Tool | Description |
|---|---|
read_todos |
List all tasks (supports hierarchical view) |
write_todos |
Bulk write/update tasks |
add_todo |
Add a single task |
update_todo_status |
Update task status by ID |
remove_todo |
Delete task by ID |
add_subtask* |
Create child task |
set_dependency* |
Link tasks with dependency |
get_available_tasks* |
List tasks ready to work on |
*Available when enable_subtasks=True
Storage Backends
In-Memory (Default)
from pydantic_ai_todo import TodoCapability, TodoStorage
storage = TodoStorage()
agent = Agent("openai:gpt-4.1", capabilities=[TodoCapability(storage=storage)])
Async Memory
from pydantic_ai_todo import TodoCapability, AsyncMemoryStorage
storage = AsyncMemoryStorage()
agent = Agent("openai:gpt-4.1", capabilities=[TodoCapability(async_storage=storage)])
PostgreSQL
from pydantic_ai_todo import TodoCapability, create_storage
storage = create_storage(
"postgres",
connection_string="postgresql://user:pass@localhost/db",
session_id="user-123", # Multi-tenancy
)
await storage.initialize()
agent = Agent("openai:gpt-4.1", capabilities=[TodoCapability(async_storage=storage)])
Event System
React to task changes:
from pydantic_ai_todo import TodoCapability, TodoEventEmitter, AsyncMemoryStorage
emitter = TodoEventEmitter()
@emitter.on_completed
async def notify_completed(event):
print(f"Task done: {event.todo.content}")
@emitter.on_created
async def notify_created(event):
print(f"New task: {event.todo.content}")
storage = AsyncMemoryStorage(event_emitter=emitter)
agent = Agent("openai:gpt-4.1", capabilities=[TodoCapability(async_storage=storage)])
API Reference
Capability
| Class | Description |
|---|---|
TodoCapability |
Pydantic AI capability — recommended way to add todo support |
Factory Functions
| Function | Description |
|---|---|
create_todo_toolset() |
Create standalone toolset (lower-level API) |
create_storage(backend, **options) |
Factory for storage backends |
get_todo_system_prompt() |
Generate system prompt with current todos |
Models
| Model | Description |
|---|---|
Todo |
Task with id, content, status, parent_id, depends_on |
TodoItem |
Input model for write_todos |
TodoEvent |
Event data with type, todo, timestamp |
TodoEventType |
CREATED, UPDATED, STATUS_CHANGED, DELETED, COMPLETED |
Storage Classes
| Class | Description |
|---|---|
TodoStorage |
Sync in-memory storage |
AsyncMemoryStorage |
Async in-memory with CRUD |
AsyncPostgresStorage |
PostgreSQL with multi-tenancy |
TodoEventEmitter |
Event emitter for callbacks |
Related Projects
| Package | Description |
|---|---|
| Pydantic Deep Agents | Full agent framework (uses this library) |
| pydantic-ai-backend | File storage and Docker sandbox |
| subagents-pydantic-ai | Multi-agent orchestration |
| summarization-pydantic-ai | Context management |
| pydantic-ai | The foundation — agent framework by Pydantic |
Contributing
git clone https://github.com/vstorm-co/pydantic-ai-todo.git
cd pydantic-ai-todo
make install
make test # 100% coverage required
License
MIT — see LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydantic_ai_todo-0.2.1.tar.gz.
File metadata
- Download URL: pydantic_ai_todo-0.2.1.tar.gz
- Upload date:
- Size: 106.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d02ef367ff3b3306a7913bf0ecba2ffa59eafe6148110f3d1df143ddc3ededd
|
|
| MD5 |
3c68fdaca80adb00d1bafc17af329216
|
|
| BLAKE2b-256 |
79307532c09e6b1b46d86e0af76b56337391299a93a809a10ff39da0841b62d2
|
Provenance
The following attestation bundles were made for pydantic_ai_todo-0.2.1.tar.gz:
Publisher:
publish.yml on vstorm-co/pydantic-ai-todo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydantic_ai_todo-0.2.1.tar.gz -
Subject digest:
5d02ef367ff3b3306a7913bf0ecba2ffa59eafe6148110f3d1df143ddc3ededd - Sigstore transparency entry: 1203514792
- Sigstore integration time:
-
Permalink:
vstorm-co/pydantic-ai-todo@01c678762fc14ce8feb156cab7c7a0af9fb19a45 -
Branch / Tag:
refs/tags/0.2.1 - Owner: https://github.com/vstorm-co
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01c678762fc14ce8feb156cab7c7a0af9fb19a45 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pydantic_ai_todo-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pydantic_ai_todo-0.2.1-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
202f8b2a3d8613aa2a422bf524d5b84e948f18e73b41ff0a51f6eb2e77e4d1fc
|
|
| MD5 |
b4798d5bed07e93be9e5fb84b6da5167
|
|
| BLAKE2b-256 |
0ed82aad24acc48b170fc1d74353fe34b9aedb8b8f71e53137d3e2e15452d3d5
|
Provenance
The following attestation bundles were made for pydantic_ai_todo-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on vstorm-co/pydantic-ai-todo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydantic_ai_todo-0.2.1-py3-none-any.whl -
Subject digest:
202f8b2a3d8613aa2a422bf524d5b84e948f18e73b41ff0a51f6eb2e77e4d1fc - Sigstore transparency entry: 1203514796
- Sigstore integration time:
-
Permalink:
vstorm-co/pydantic-ai-todo@01c678762fc14ce8feb156cab7c7a0af9fb19a45 -
Branch / Tag:
refs/tags/0.2.1 - Owner: https://github.com/vstorm-co
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01c678762fc14ce8feb156cab7c7a0af9fb19a45 -
Trigger Event:
release
-
Statement type: