Instructions for AI coding assistants working on this repository.
pydantic-ai-todo is a standalone todo/task planning toolset for pydantic-ai agents. It provides read_todos and write_todos tools that work with any pydantic-ai agent without requiring specific dependencies.
| Task | Command |
|---|---|
| Install | uv sync --group dev |
| Test | uv run pytest |
| Test + Coverage | uv run coverage run -m pytest && uv run coverage report |
| Lint | uv run ruff check . |
| Format | uv run ruff format . |
| Typecheck | uv run pyright |
| Build | uv run python -m build |
pydantic_ai_todo/
├── types.py # Todo, TodoItem - Pydantic models
├── storage.py # TodoStorage, TodoStorageProtocol - state management
├── toolset.py # create_todo_toolset() - main factory
└── __init__.py # public API
Tools capture storage via closure, NOT through ctx.deps:
def create_todo_toolset(storage=None):
_storage = storage or TodoStorage()
@toolset.tool
async def read_todos() -> str: # No ctx parameter!
return format(_storage.todos)This pattern ensures compatibility with ANY pydantic-ai agent deps type.
- Coverage: 100% required - check with
uv run coverage report - Types: Pyright strict mode - all functions need type annotations
- Style: ruff handles formatting and linting
Tests are in tests/ directory. Use pytest-asyncio for async tests:
async def test_write_todos():
storage = TodoStorage()
toolset = create_todo_toolset(storage=storage)
# Test using toolset.tools dict- Run tests after changes:
uv run pytest - Check coverage stays at 100%
- Run
uv run pyrightfor type errors - Format with
uv run ruff format .