This shows you how to thread external resources like database connections, API clients, and user context into PydanticAI agents through the RunContext pattern. You define a deps_type dataclass, access it via ctx.deps in your tools and system prompts, then pass the actual dependencies at runtime when you call agent.run(). The type safety is real: Agent[DepsType, OutputType] gives you full static checking across tools, instructions, and run calls. Most useful when your agent needs to hit external services or maintain per-request state like user sessions. The gates section is smart about verifying every ctx.deps access maps to an actual field and your tests don't mock away half the dependencies your tools actually touch.
npx skills add https://github.com/existential-birds/beagle --skill pydantic-ai-dependency-injection