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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydantic_ai_todo-0.1.2.tar.gz
  • Upload date:
  • Size: 192.8 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.2.tar.gz
Algorithm Hash digest
SHA256 60e22338c973e86fea15d6d2dfeaa2e091a397257f000daad013ba58c6bb75ba
MD5 bcba0d091498fd188c53544504011be2
BLAKE2b-256 d4964218f8bb50f66e246983267bf0348ce217038fdf9bf070ec0a2077961d06

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pydantic_ai_todo-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 94ea2c5ef24f23eb3db734afb8659d7b60beb9441feadd1a537dafe27d18c070
MD5 2242435126f1dee9d1be6d19e38449c7
BLAKE2b-256 c2cd21936e6c91adf2fb269fa2916fec596493ab7e0169489014bcb672b6edcd

See more details on using hashes here.

Provenance

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