existential-birds/beagle/pydantic-ai-common-pitfalls
Claude Code and agent skill by existential-birds/beagle
- community
Checking that the SKILL.md file is still in the repository.
Avoid common mistakes and debug issues in PydanticAI agents. Use when encountering errors, unexpected behavior, or when reviewing agent implementations.
Install
npx vskill@latest install existential-birds/beagle/pydantic-ai-common-pitfallsSKILL.md
PydanticAI Common Pitfalls and Debugging
Tool Decorator Errors
Wrong: RunContext in tool_plain
Fix: Use @agent.tool if you need context:
Wrong: Missing RunContext in tool
Fix: Add RunContext as first parameter:
Wrong: RunContext not first
Fix: RunContext must always be the first parameter.
Valid Patterns (Not Errors)
Raw Function Tool Registration
The following pattern IS valid and supported by pydantic-ai:
Why this works: PydanticAI inspects function signatures. If the first parameter is RunContext[T], it's treated as a context-aware tool. No decorator required.
Reference: https://ai.pydantic.dev/agents/#registering-tools-via-the-tools-argument
Do NOT flag code that passes functions with RunContext signatures to Agent(tools=[...]). This is equivalent to using @agent.tool and is explicitly documented.
Dependency Type Mismatches
Wrong: Missing deps at runtime
Fix: Always provide deps when deps_type is set:
Wrong: Wrong deps type
Output Type Issues
Pydantic validation fails
Fix: Increase retries or improve prompt:
Complex nested types
Fix: Simplify or use intermediate models:
Async vs Sync Mistakes
Wrong: Calling async in sync context
Fix: Use run_sync or make handler async:
Wrong: Blocking in async tools
Fix: Use async I/O:
Model Configuration Errors
Missing API key
Fix: Set environment variable or use defer_model_check:
Invalid model string
Fix: Use valid provider:model format.
Streaming Issues
Wrong: Using result before stream completes
Wrong: Not iterating stream
Fix: Always consume the stream:
Tool Return Issues
Wrong: Returning non-serializable
Fix: Return serializable types (str, dict, Pydantic model):
Debugging Tips
Gates (ambiguous failures)
When the agent misbehaves but the stack trace or error string is unclear, follow in order; do not skip ahead.
- Capture evidence — Re-run with
capture_run_messages()or, afterrun/run_sync, inspectresult.all_messages()(or print message types in order). Pass: You can name the message part type and one line of content that explains the failure (e.g.RetryPromptPart, tool return, model text). - Separate model from schema — If validation or
RetryPromptPartappears, compare the last model message to youroutput_typefields and types. Pass: You identified a concrete mismatch (missing field, wrong type, refusal) before only raisingretriesor changing the model. - Confirm deps on every path — If tools or deps fail, verify each call site (
run,run_sync,run_stream) suppliesdeps=...whendeps_typeis set. Pass: A minimal repro with explicitdepsmatches or rules out a deps wiring bug.
Enable tracing
Capture messages
Check model responses
Common Error Messages
| Error | Cause | Fix | |
|---|---|---|---|
First parameter... RunContext | @agent.tool missing ctx | Add ctx: RunContext[...] | |
RunContext... only... context | @agent.tool_plain has ctx | Remove ctx or use @agent.tool | |
Unknown model provider | Invalid model string | Use valid provider:model | |
ModelAPIError | API auth/quota | Check API key, limits | |
RetryPromptPart in messages | Validation failed | Check output_type, increase retries |
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/beagle-ai/skills/pydantic-ai-common-pitfalls/SKILL.md
Popularity
- Repository stars
- 78
- Repository forks
- 9
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 18 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/existential-birds/beagle/pydantic-ai-common-pitfalls)