fullfran-pydantic-ai
Installation
SKILL.md
Pydantic AI Expert Skill
This skill provides patterns for defining agents, dependencies, and tools using Pydantic AI.
🤖 Agent Definition
- State Management: Use
StateDeps[T]to pass dependencies (DB clients, settings) to agents. - System Prompts: Define complex prompts in
src/prompts.py. Use@agent.instructionsfor dynamic context. - Model Choice: Use
OpenAIModelas a base for OpenAI-compatible providers (OpenRouter, Ollama) viaOpenAIProvider.
🛠️ Tool Patterns
- Return Strings: Agents work best with text. Tools should return formatted strings, not Pydantic objects.
- Resource Management: Initialize and cleanup DB connections properly within the tool or via injected deps.
- Error Handling: Tools should catch exceptions and return helpful error messages to the agent rather than crashing.