Skip to content
Pydantic AI

Task Automation Agent with Pydantic AI

Build a task automation agent that creates, assigns, and tracks tasks across your project management workflow — using Pydantic AI.

automationproject managementtasksworkflow

Working Code

Pydantic AI
from pydantic_ai import Agent, RunContext
agent = Agent(
"openai:gpt-4o",
system_prompt="You are a project management assistant. Help organize tasks: create new ones, track progress, and update statuses. Be proactive about suggesting task breakdowns.",
)
@agent.tool
async def create_task(ctx: RunContext, title: str, description: str, assignee: str = "") -> str:
"""Create a new task in the project."""
task_id = await project.create_task(title=title, description=description, assignee=assignee)
return f"Task created: #{task_id} - {title}"
@agent.tool
async def list_tasks(ctx: RunContext, status: str = "open") -> str:
"""List tasks filtered by status (open, in_progress, done)."""
tasks = await project.list_tasks(status=status)
return "\n".join(f"#{t.id} [{t.status}] {t.title} -> {t.assignee}" for t in tasks)
@agent.tool
async def update_task(ctx: RunContext, task_id: int, status: str) -> str:
"""Update task status."""
await project.update_task(task_id, status=status)
return f"Task #{task_id} updated to {status}"
result = await agent.run("Break down 'Launch new website' into subtasks and assign them to the team")
print(result.output)

Step by Step

1

Install dependencies

Install Pydantic AI and the required tools for this use case.

2

Define your tools

Create the domain-specific tool functions your agent will use to interact with external services.

3

Create the agent and run

Initialize the Pydantic AI agent with your tools, set the system prompt, and execute a query.

Ready to build with Pydantic AI?

Generate a production-ready project with Pydantic AI pre-configured — FastAPI + Next.js, auth, streaming, and more.

Get Started

Ready to build your first production AI agent?

Open-source tools, battle-tested patterns, zero boilerplate. Configure your stack and ship in minutes — not months.