Skip to main content

Todo/task planning toolset for pydantic-ai agents

Project description

pydantic-ai-todo

Looking for a complete agent framework? Check out pydantic-deep - a full-featured deep agent framework with planning, subagents, and skills system built on pydantic-ai.

Need file storage or Docker sandbox? Check out pydantic-ai-backend - file storage and sandbox backends that work with any pydantic-ai agent.

Want a full-stack template? Check out fastapi-fullstack - production-ready AI/LLM application template with FastAPI, Next.js, and pydantic-deep integration.

PyPI version CI Coverage Python License

Todo/task planning toolset for pydantic-ai agents.

This library was extracted from pydantic-deep to provide standalone task planning for any pydantic-ai agent without requiring the full framework.

Provides read_todos and write_todos tools that help AI agents track and manage tasks during a session.

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.1.tar.gz (207.4 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.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydantic_ai_todo-0.1.1.tar.gz
  • Upload date:
  • Size: 207.4 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.1.tar.gz
Algorithm Hash digest
SHA256 ee0ea9726a456325a1926f3d3c97f2c88292f69b1afe63476165b1c2853581ec
MD5 c5589d3a6533e93011c42ff0d766065b
BLAKE2b-256 9292123a99e75b4c9a219c235a08c2b06e1f7b95394de187fe45debc56f636ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_ai_todo-0.1.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_ai_todo-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c289ebe51e6f5975c51e3a5337578fd7c1b03a442de2628ac9d134e251c31306
MD5 2a5c75b75b26f3b488785cc7cdde32e5
BLAKE2b-256 793717770c8f3a21584ec30ab31aec389f0b3c06e4b212742eaa8d37dfa31b68

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_ai_todo-0.1.1-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