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.
📺 CLI & Streaming
- Rich Integration: Use
Richto display real-time streaming of agent output and tool call details. - Node Handling: Implement logic for
userprompt,modelrequest,call_tools, andendnodes in the CLI. - Transparency: Always show the user which tool is being called and with what parameters.