Todo/task planning toolset for pydantic-ai agents
Project description
pydantic-ai-todo
Todo/task planning toolset for pydantic-ai agents. Part of the pydantic-deep ecosystem.
Provides read_todos and write_todos tools that help AI agents track and manage tasks during a session. Works with any pydantic-ai agent - no specific dependencies required.
Installation
pip install pydantic-ai-todo
Or with uv:
uv add pydantic-ai-todo
Quick Start
from pydantic_ai import Agent
from pydantic_ai_todo import create_todo_toolset
# Create an agent with todo capabilities
agent = Agent(
"openai:gpt-4.1",
toolsets=[create_todo_toolset()],
)
# Run the agent
result = await agent.run("Create a todo list for building a website")
Usage with Storage Access
If you need to access the todos after the agent runs:
from pydantic_ai import Agent
from pydantic_ai_todo import create_todo_toolset, TodoStorage
# Create storage and toolset
storage = TodoStorage()
toolset = create_todo_toolset(storage=storage)
agent = Agent("openai:gpt-4.1", toolsets=[toolset])
# Run the agent
result = await agent.run("Plan the implementation of a REST API")
# Access todos directly
for todo in storage.todos:
print(f"[{todo.status}] {todo.content}")
Custom Storage
You can implement custom storage (e.g., for persistence):
import json
from pydantic_ai_todo import create_todo_toolset, TodoStorageProtocol, Todo
class RedisTodoStorage:
"""Store todos in Redis."""
def __init__(self, redis_client):
self._redis = redis_client
@property
def todos(self) -> list[Todo]:
data = self._redis.get("todos")
if not data:
return []
return [Todo(**t) for t in json.loads(data)]
@todos.setter
def todos(self, value: list[Todo]) -> None:
self._redis.set("todos", json.dumps([t.model_dump() for t in value]))
# Use with agent
storage = RedisTodoStorage(redis.Redis())
agent = Agent("openai:gpt-4.1", toolsets=[create_todo_toolset(storage)])
System Prompt Integration
Include current todos in the system prompt:
from pydantic_ai_todo import get_todo_system_prompt, TodoStorage
storage = TodoStorage()
# ... agent populates todos ...
# Generate system prompt section with current todos
prompt_section = get_todo_system_prompt(storage)
API Reference
create_todo_toolset(storage=None, *, id=None)
Creates a todo toolset with read_todos and write_todos tools.
Parameters:
storage: OptionalTodoStorageProtocolimplementation. Defaults to in-memoryTodoStorage.id: Optional unique ID for the toolset.
Returns: FunctionToolset[Any]
get_todo_system_prompt(storage=None)
Generates a system prompt section for task management.
Parameters:
storage: Optional storage to read current todos from.
Returns: str - System prompt with optional current todos section.
Todo
Pydantic model for a todo item.
class Todo(BaseModel):
content: str # Task description in imperative form
status: Literal["pending", "in_progress", "completed"]
active_form: str # Present continuous form (e.g., "Implementing...")
TodoStorage
Default in-memory storage implementation.
storage = TodoStorage()
storage.todos = [Todo(...), Todo(...)]
print(storage.todos)
TodoStorageProtocol
Protocol for custom storage implementations. Must have a todos property with getter and setter.
Related Projects
- pydantic-deep - Deep agent framework built on pydantic-ai
- pydantic-ai - Agent framework for Python
- pydantic - Data validation library
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.1.0.tar.gz.
File metadata
- Download URL: pydantic_ai_todo-0.1.0.tar.gz
- Upload date:
- Size: 192.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
082e8f187a737d7a48243282d37e1109ac3d0b08662b4e1247efc9097ffbe211
|
|
| MD5 |
ef85af42ddcf4abb8115385beb78c5fd
|
|
| BLAKE2b-256 |
efef9d7f1fd46874dc1cbe33b0c12a5d4b46fdb3e7207913cab924b30221b353
|
Provenance
The following attestation bundles were made for pydantic_ai_todo-0.1.0.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.1.0.tar.gz -
Subject digest:
082e8f187a737d7a48243282d37e1109ac3d0b08662b4e1247efc9097ffbe211 - Sigstore transparency entry: 776113277
- Sigstore integration time:
-
Permalink:
vstorm-co/pydantic-ai-todo@fa5c5bad0b51a4dfd37e0a8e5bcec12703bfa519 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/vstorm-co
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fa5c5bad0b51a4dfd37e0a8e5bcec12703bfa519 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pydantic_ai_todo-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pydantic_ai_todo-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.8 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 |
c1c3dee06a73bc78e9b8a52e0a1905ead46daf17c7e9118e32fa7aeaf40b1fe0
|
|
| MD5 |
13c9b1fd2455aea10d35915dfe586797
|
|
| BLAKE2b-256 |
a88c7aa407da2490733c7a997817016894990ebdfbc52a8814f28fa8d25ad7fd
|
Provenance
The following attestation bundles were made for pydantic_ai_todo-0.1.0-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.1.0-py3-none-any.whl -
Subject digest:
c1c3dee06a73bc78e9b8a52e0a1905ead46daf17c7e9118e32fa7aeaf40b1fe0 - Sigstore transparency entry: 776113278
- Sigstore integration time:
-
Permalink:
vstorm-co/pydantic-ai-todo@fa5c5bad0b51a4dfd37e0a8e5bcec12703bfa519 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/vstorm-co
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fa5c5bad0b51a4dfd37e0a8e5bcec12703bfa519 -
Trigger Event:
release
-
Statement type: