Install any skill in seconds. Free to start, no credit card required.
Get Started Free →majiayu000/pydantic-ai-dependency-injection
Implement dependency injection in PydanticAI agents using RunContext and deps_type.
Passed 21 of 23 test cases with the skill, and 18 of 23 without it.
and 1 more in the full report
4 fixed17 passed either way1 still failing1 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 4 test cases the skill fixed. Same model, same prompt, with and without the skill.
After running `result = await agent.run('Calculate total', deps=deps)` on a PydanticAI agent with a defined output model, which attribute on `result` holds the validated output model instance?
| Checked | Without skill | With skill |
|---|---|---|
| The response identifies .output as the attribute containing the execution result. | Missed | Passed |
The instructions your model reads when the skill loads.
Dependencies flow through RunContext:
from dataclasses import dataclass
from pydantic_ai import Agent, RunContext
@dataclass
class Deps:
db: DatabaseConn
api_client: HttpClient
user_id: int
agent = Agent(
'openai:gpt-4o',
deps_type=Deps, # Type for static analysis
)
@agent.tool
async def get_user_balance(ctx: RunContext[Deps]) -> float:
"""Get the current user's account balance."""
return await ctx.deps.db.get_balance(ctx.deps.user_id)
# At runtime, provide deps
result = await agent.run(
'What is my balance?',
deps=Deps(db=db_conn, api_client=client, user_id=123)
)
Use dataclasses or Pydantic models:
from dataclasses import dataclass
from pydantic import BaseModel
test cases passed, vs 18 / 23 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.