pydantic-ai-tool-system

Register PydanticAI tools with context-aware decorators and Google-style docstrings.

75|9|Updated Dec 21, 2025
One-click install
npx skills add https://github.com/anderskev/beagle --skill pydantic-ai-tool-system
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pydantic-ai-tool-system
Source: https://github.com/anderskev/beagle/tree/main/skills/pydantic-ai-tool-system
Command: npx skills add https://github.com/anderskev/beagle --skill pydantic-ai-tool-system

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps teams register and implement PydanticAI tools with proper context handling, type annotations, and docstrings to enable reliable tool usage by agents.

Core Features & Use Cases

  • Tool registration with two decorators: one supporting RunContext and one plain version without context.
  • Enforced docstrings and Google/Sphinx formats for clear tool semantics.
  • Support for various return types (string, dict, Pydantic models, ToolReturn).
  • Access to context (deps, model info, usage, retry, messages) for dynamic tool behavior.
  • Toolsets and dynamic preparation to filter or modify tools per request.

Quick Start

Define an Agent, decorate a function with @agent.tool (ctx-aware) or @agent.tool_plain (no ctx), ensure docstrings, and register toolsets for reuse.

Frequently Asked Questions about pydantic-ai-tool-system

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I register tools for PydanticAI agents with context access?

Register tools using @agent.tool decorator for context-aware functions or @agent.tool_plain for plain functions. Both require Google-style docstrings and type annotations. Context-aware tools expose RunContext data including dependencies, model info, usage metrics, and message history for dynamic tool behavior.

What return types do PydanticAI tools support?

PydanticAI tools support multiple return types: strings, dictionaries, Pydantic models, and ToolReturn objects. Choose based on your agent's needs—simple strings for basic responses, Pydantic models for structured data, or ToolReturn for advanced control over tool execution results.

How do I organize tools into reusable toolsets for agents?

Group registered tools into toolsets for reuse across multiple agents. Toolsets enable dynamic preparation to filter or modify tools per request, allowing you to customize tool availability based on context, request type, or agent requirements without redefining individual tools.

Can I access agent context like dependencies and message history inside tools?

Yes, use the @agent.tool decorator (not @agent.tool_plain) to receive RunContext in your tool function. RunContext exposes dependencies, model information, usage metrics, retry state, and message history, enabling tools to adapt behavior based on request-specific data and agent state.

What docstring format is required for PydanticAI tool functions?

PydanticAI tools require Google-style or Sphinx-format docstrings. These formats ensure clear tool semantics and are enforced during registration. Proper docstrings help agents understand tool purpose and parameters, improving function-calling reliability and agent decision-making.

How do I implement dynamic tool preparation for per-request filtering?

Use toolset dynamic preparation to filter or modify tools per request before agent execution. This approach lets you customize tool availability, adjust tool parameters, or exclude tools based on request context, model info, or runtime dependencies without creating separate tool registrations.