
Pydantic Ai Common Pitfalls
Catches the decorator and type annotation mistakes that trip up PydanticAI users most often. Shows you which tools need RunContext and which don't, how to fix "First parameter must be annotated with RunContext" errors, and why your deps aren't wiring up correctly. The debugging section is genuinely helpful: it walks you through message capture, explains when raw function registration is actually valid (despite looking wrong), and includes a gate checklist for those frustrating cases where the agent just silently does the wrong thing. Worth keeping open when you're setting up new agents or reviewing tool definitions, especially if you're switching between sync and async patterns.
- skills.sh installs
- 221
- GitHub stars
- 87
- last updated
- Aug 21, 2026
Install
$ npx -y skills add existential-birds/beagle --skill pydantic-ai-common-pitfalls --agent claude-codeInstalls into .claude/skills of the current project.
Files
PydanticAI Common Pitfalls and Debugging
Tool Decorator Errors
Wrong: RunContext in tool_plain
# ERROR: RunContext not allowed in tool_plain
@agent.tool_plain
async def bad_tool(ctx: RunContext[MyDeps]) -> str:
return "oops"
# UserError: RunContext annotations can only be used with tools that take context
Fix: Use @agent.tool if you need context:
@agent.tool
async def good_tool(ctx: RunContext[MyDeps]) -> str:
return "works"
Wrong: Missing RunContext in tool
# ERROR: First param must be RunContext
@agent.tool
def bad_tool(user_id: int) -> str:
return "oops"
# UserError: First parameter of tools that take context must be annotated with RunContext[...]
Fix: Add RunContext as first parameter:
@agent.tool
def good_tool(ctx: RunContext[MyDeps], user_id: int) -> str:
return "works"
Wrong: RunContext not first
# ERROR: RunContext must be first parameter
@agent.tool
def bad_tool(user_id: int, ctx: RunContext[MyDeps]) -> str:
return "oops"
Fix: RunContext must always be the first parameter.
Valid Patterns (Not Errors)
Raw Function Tool Registration
Sponsors
Details
- Repository
- github.com/existential-birds/beagle
- Categories
- AI & Agent Building, Debugging, Python
- First seen
- Jun 3, 2026
More from existential-birds/beagle
All 40- Pydantic Ai Agent Creation219
- Agent Architecture Analysis217
- Ai Elements209
- Go Code Review204
- Shadcn Code Review204
- Swift Testing Code Review194
- Sqlite Vec171
- Pydantic Ai Tool System161
- Deepagents Architecture160
- Langgraph Implementation160
- Pydantic Ai Testing146
- Pydantic Ai Dependency Injection141
- Deepagents Implementation140
- Deepagents Code Review132
- Github Projects120
- Pydantic Ai Model Integration120
- React Flow1.3K
- Python Code Review928
- Langgraph Code Review887
- Tailwind V4817
- React Flow Advanced643
- React Router V7577
- React Flow Architecture536
- Vitest Testing471