Skip to main content

Todo/task planning toolset for pydantic-ai agents

Project description

Todo Toolset for Pydantic AI

Task Planning and Tracking for AI Agents

PyPI version Python 3.10+ License: MIT CI Pydantic AI

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. TodoCapability handles 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


Need help implementing this in your company?

We're Vstorm — an Applied Agentic AI Engineering Consultancy
with 30+ production AI agent implementations.

Talk to us



Made with ❤️ by Vstorm

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_ai_todo-0.2.3.tar.gz (112.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_ai_todo-0.2.3-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_ai_todo-0.2.3.tar.gz.

File metadata

  • Download URL: pydantic_ai_todo-0.2.3.tar.gz
  • Upload date:
  • Size: 112.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pydantic_ai_todo-0.2.3.tar.gz
Algorithm Hash digest
SHA256 5eed657077f056ab55b8468c75deab8ed9312825f1b3bf76eadb87c6769ecf08
MD5 82679dbebf7165217e22cae3e9dabe75
BLAKE2b-256 7a4bc83820506b0d4e932556bf01e712b069b8cdb156aed0a43d600b419ad4ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_ai_todo-0.2.3.tar.gz:

Publisher: publish.yml on vstorm-co/pydantic-ai-todo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydantic_ai_todo-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_ai_todo-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9b46ad0bc28de00c7dadb39c902d82fabb37f71b51f3ae63dfbd269c6f5d10c7
MD5 baba373d693aa758808b2c0357b3335c
BLAKE2b-256 0a098f138d41c88c07f9e8268ccfbd104cafd3ec20ced3ec4bc4d72223d4da46

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_ai_todo-0.2.3-py3-none-any.whl:

Publisher: publish.yml on vstorm-co/pydantic-ai-todo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page