Skip to main content

The Storybook for AI Agents

Project description

Agent Playbook 🔬

The Storybook for AI Agents - Build, test, and showcase your pydantic-ai agents in an interactive playground.

Python 3.10+ License: AGPL v3


🎯 Motivation

Building AI agents is hard. Testing them is even harder.

When developing UI components, tools like Storybook revolutionized the workflow by providing an isolated environment to build, test, and showcase components. Agent Playbook brings this same philosophy to AI agent development.

The Problem

  • Slow iteration cycles - Running agents in full applications slows down development
  • Hard to debug - Understanding agent behavior, tool calls, and decision-making is opaque
  • Difficult to demonstrate - Showing agent capabilities to stakeholders requires complex setups
  • No organized testing - Agents scattered across codebases without a unified testing environment

The Solution

Agent Playbook automatically discovers your pydantic-ai agents, loads them into an interactive web playground, and lets you test, debug, and showcase them in real-time with full visibility into their thinking process and tool executions.

https://gist.github.com/user-attachments/assets/eebacd09-e9da-43a9-825e-7e67504c86a7

✨ Key Features

  • 🔍 Auto-Discovery - Automatically finds and loads agents from your codebase
  • 🎮 Interactive Playground - Beautiful web UI for testing agents in real-time
  • 🔄 Streaming Support - Watch agent responses, thinking, and tool calls as they happen
  • 🧩 Scenario Configuration - Test agents with different configurations
  • 🛠️ Tool Visualization - See exactly what tools agents call with arguments and results

🚀 Quick Start

Installation

pip install agent-playbook

(The CLI command is playbook, not agent-playbook)

Basic Example

Step 1: Define your agent (support_agent.py)

from pydantic_ai import Agent, RunContext
from pydantic import BaseModel


class SupportDeps(BaseModel):
    company_name: str
    support_email: str


support_agent = Agent(model="openai:gpt-4", deps_type=SupportDeps)


@support_agent.system_prompt
async def support_system_prompt(ctx: RunContext[SupportDeps]) -> str:
    return f"You are a helpful customer support agent for {ctx.deps.company_name}."


@support_agent.tool
async def check_order_status(ctx: RunContext[SupportDeps], order_id: str) -> str:
    """Check the status of a customer order."""
    return f"Order {order_id} is being processed and will ship in 2-3 business days."


@support_agent.tool
async def create_ticket(ctx: RunContext[SupportDeps], issue: str, priority: str) -> str:
    """Create a support ticket."""
    return f"Ticket created with {priority} priority. Contact: {ctx.deps.support_email}"

Step 2: Export scenarios (support_agent__scenarios.py)

Agent Playbook auto-discovers modules ending with __scenarios and registers the agents. Use the export() function to define different configurations:

from agent_playbook import export
from .support_agent import SupportDeps, support_agent

export(
    agent=support_agent,
    scenarios=[
        {
            "name": "ACME Corp",
            "settings": SupportDeps(
                company_name="ACME Corporation", support_email="support@acme.com"
            ),
        },
        {
            "name": "TechStart",
            "settings": SupportDeps(
                company_name="TechStart Inc", support_email="help@techstart.io"
            ),
        },
    ],
)

Start the server and open http://localhost:8765:

playbook myapp.agents --reload

🛠️ CLI Reference

playbook <package> [options]

Options:
  --host TEXT      Server host (default: 127.0.0.1)
  --port INTEGER   Server port (default: 8765)
  --reload         Auto-reload on code changes

🤝 Contributing

Contributions are welcome! Fork the repository, create a feature branch, and submit a Pull Request.

📄 License

Licensed under AGPL-3.0. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_playbook-0.1.1.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_playbook-0.1.1-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file agent_playbook-0.1.1.tar.gz.

File metadata

  • Download URL: agent_playbook-0.1.1.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.12 Linux/6.11.0-1018-azure

File hashes

Hashes for agent_playbook-0.1.1.tar.gz
Algorithm Hash digest
SHA256 37362fbce7e6e0843cb31e23daafe52da03f04561701a10eb16b4e90f37f52ad
MD5 47c44dba711d205db33d6d9929f590ae
BLAKE2b-256 96b0dcca1b7a2136836844cafc615bac2dc8d0f27730ab3bb6a8fd99208985fe

See more details on using hashes here.

File details

Details for the file agent_playbook-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: agent_playbook-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.12 Linux/6.11.0-1018-azure

File hashes

Hashes for agent_playbook-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 87a30d8a152aeca160026e5b4f650535442fe488620867dc8739c02fddfcc20a
MD5 4e5af25d61d4a1a7e8b3c0f0295ecb64
BLAKE2b-256 664e53cf96f43a925ea839cc7262194fb33d5d2b71c5308962b13a2257ad01be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page