Skip to main content

Todo/task planning toolset for pydantic-ai agents

Project description

pydantic-ai-todo

PyPI version CI Coverage Python License

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: Optional TodoStorageProtocol implementation. Defaults to in-memory TodoStorage.
  • 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

License

MIT

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.1.0.tar.gz (192.1 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.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

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

Hashes for pydantic_ai_todo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 082e8f187a737d7a48243282d37e1109ac3d0b08662b4e1247efc9097ffbe211
MD5 ef85af42ddcf4abb8115385beb78c5fd
BLAKE2b-256 efef9d7f1fd46874dc1cbe33b0c12a5d4b46fdb3e7207913cab924b30221b353

See more details on using hashes here.

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

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.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_ai_todo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1c3dee06a73bc78e9b8a52e0a1905ead46daf17c7e9118e32fa7aeaf40b1fe0
MD5 13c9b1fd2455aea10d35915dfe586797
BLAKE2b-256 a88c7aa407da2490733c7a997817016894990ebdfbc52a8814f28fa8d25ad7fd

See more details on using hashes here.

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

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