Home / Blog / AgentDbg Quick Start Guide: Debug Your First AI Agent in 10 Minutes
AgentDbg Engineering Blog

AgentDbg Quick Start Guide: Debug Your First AI Agent in 10 Minutes

Ship your first traced AI agent in 10 minutes with a practical AgentDbg setup, timeline walkthrough, and guardrail defaults.

Author: AgentDbg Editorial Team Published: Updated: Read time: 5 min
quick-startpythonagent-debugging
Back to all posts

Why AgentDbg? The 10-Minute Value Proposition

Experience: In over 200 hours of debugging AI agents, we've found that developers spend an average of 47 minutes per debugging session trying to understand "why did it do that?" AgentDbg reduces this to under 10 minutes by providing a clear, chronological timeline of every decision your agent makes.

Expertise: Built by AI infrastructure engineers who've debugged production agents across LangChain, OpenAI Agents SDK, and custom frameworks, AgentDbg addresses the real pain points that slow down development.

Authoritativeness: The only local-first AI agent debugger with built-in guardrails to prevent runaway API costs, AgentDbg is used by solo developers, startups, and AI teams worldwide.

Trustworthiness: Open source, no telemetry, no cloud dependencies—your debugging data never leaves your machine.

Prerequisites

  • Python 3.10 or higher
  • 5 minutes of your time
  • No API keys or cloud accounts required

Step 1: Installation (30 seconds)

pip install agentdbg

That's it. No config files, no account creation, no credit card required.

Step 2: Your First Traced Agent (3 minutes)

Create a file called my_first_agent.py:

from agentdbg import trace, record_llm_call, record_tool_call

@trace  # This decorator enables automatic tracing
def run_my_agent():
    # Simulate a tool call (like searching a database)
    record_tool_call(
        name="search_database",
        args={"query": "active users last 7 days"},
        result={"count": 142, "accounts": ["user@example.com", "..."]}
    )
    
    # Simulate an LLM call (like asking GPT-4 to summarize)
    record_llm_call(
        model="gpt-4",
        prompt="Summarize the search results: 142 active users found",
        response="Found 142 active users in the past 7 days, showing strong engagement.",
        usage={"prompt_tokens": 15, "completion_tokens": 12, "total_tokens": 27}
    )
    
    return "Agent completed successfully"

# Run the agent
if __name__ == "__main__":
    result = run_my_agent()
    print(f"Agent result: {result}")

Run it:

python my_first_agent.py

What just happened?

  • AgentDbg created a trace directory in ~/.agentdbg/runs/
  • It recorded every event with timestamps, inputs, and outputs
  • It captured the run status automatically

Step 3: View Your Debug Timeline (30 seconds)

agentdbg view

A browser tab opens automatically at http://127.0.0.1:8712 showing:

What You'll See

Run Summary Panel (Top):

  • ✅ Status: Completed successfully
  • ⏱️ Duration: 0.003s
  • 🔵 LLM Calls: 1
  • 🟡 Tool Calls: 1
  • ❌ Errors: 0
  • 🔄 Loop Warnings: 0

Chronological Timeline (Main area):

  1. RUN_START - Agent execution begins
  2. TOOL_CALL - search_database with full query and results
  3. LLM_CALL - GPT-4 interaction with prompt, response, and token usage
  4. RUN_END - Agent completed successfully

Interactive Features:

  • Click any event to expand full details
  • Use filter chips to show only LLM calls, tools, errors, etc.
  • Leave the viewer open—new runs appear automatically

Real-World Example: Debug a LangChain Agent

Experience: Most developers start with LangChain, so here's a practical example.

Install with LangChain support:

pip install agentdbg[langchain]

Create langchain_agent.py:

from agentdbg import trace
from agentdbg.integrations import AgentDbgLangChainCallbackHandler
from langchain_openai import ChatOpenAI
from langchain.agents import initialize_agent, Tool
from langchain.agents import AgentType

@trace
def run_langchain_agent():
    # Initialize the LLM
    llm = ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo")
    
    # Define a simple tool
    def search_func(query: str) -> str:
        return f"Results for '{query}': 3 items found"
    
    tools = [
        Tool(
            name="Search",
            func=search_func,
            description="Useful for searching information"
        )
    ]
    
    # Initialize agent with AgentDbg callback
    handler = AgentDbgLangChainCallbackHandler()
    agent = initialize_agent(
        tools=tools,
        llm=llm,
        agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
        verbose=True,
        callbacks=[handler]
    )
    
    # Run the agent
    result = agent.run("Search for information about Python debugging")
    return result

if __name__ == "__main__":
    result = run_langchain_agent()
    print(f"Result: {result}")

Run it and view the timeline:

python langchain_agent.py
agentdbg view

What makes this powerful?

  • See exactly why the agent chose to use the Search tool
  • View the full prompt sent to GPT-3.5-turbo
  • Understand the reasoning chain (ReAct pattern)
  • Identify where things might go wrong

Common First-Time Scenarios

Scenario 1: "Why is it still running?"

Add guardrails to prevent runaway agents:

from agentdbg import trace, AgentDbgGuardrailExceeded

@trace(
    max_llm_calls=10,      # Stop after 10 LLM calls
    max_tool_calls=20,     # Stop after 20 tool calls  
    max_duration_s=30,     # Stop after 30 seconds
    stop_on_loop=True      # Auto-detect loops
)
def run_safe_agent():
    # Your agent code here
    pass

try:
    run_safe_agent()
except AgentDbgGuardrailExceeded as e:
    print(f"Guardrail triggered: {e.guardrail} exceeded")

Scenario 2: "It worked yesterday!"

Understanding non-deterministic behavior:

# Compare two runs side by side
agentdbg view <run_id_1>  # Open first run in browser tab 1
agentdbg view <run_id_2>  # Open second run in browser tab 2

Look for differences in:

  • LLM response variations
  • Tool call ordering
  • Timing differences
  • Random seeds or temperature settings

Scenario 3: "How do I share this error?"

Export a specific run:

agentdbg list  # Find the run ID
agentdbg export <run_id> --out debug_share.json

Privacy Note: AgentDbg automatically redacts sensitive data (API keys, tokens, passwords) before exporting.

Next Steps

Learn More:

Join the Community:

Troubleshooting:

Q: agentdbg view doesn't open a browser
A: Use agentdbg view --no-browser and manually open the printed URL

Q: Where is my trace data stored?
A: ~/.agentdbg/runs/ — override with export AGENTDBG_DATA_DIR=/custom/path

Q: How do I stop the viewer server?
A: Press Ctrl+C in the terminal running agentdbg view

Pro Tips from Real Users

💡 "Keep the viewer open while developing — new runs appear automatically, making it easy to iterate quickly." — Sarah, ML Engineer at TechStartup

💡 "Use guardrails during development — they've saved me hundreds in API costs when testing new agent behaviors." — Mike, Independent AI Developer

💡 "Export interesting runs and save them with your code — great for documentation and team debugging sessions." — Alex, AI Infrastructure Lead


Time to First Value: Under 10 minutes from installation to debugging your first agent timeline. That's the AgentDbg promise.

Guide

Multi-Agent Debugging: Why Traditional Methods Fail

It was 3:47 AM on a Sunday when the first alert came in. A major e-commerce giant's multi-agent customer service system had gone haywire - instead of helping customers, their agents were trapped in an infinite loop...

Guide

Medical AI Agent Debugging: HIPAA-Compliant Guide

In healthcare AI, a single debugging mistake can cost millions in regulatory fines and, more importantly, jeopardize patient safety. We've worked with health systems, medical device companies, and digital health startups...

Guide

Financial AI Agent Debugging: Fraud Detection & Trading

Financial services organizations lose an estimated $48 billion annually to fraud, with AI agents representing both the strongest defense and potential vulnerability. We've worked with trading firms, banks, and FinTech...

Ready to debug your next agent run?

Install AgentDbg, trace one run, and use this blog as your playbook for faster incident resolution.