Skip to main content
Local Debugging lets you develop and test agents on your machine while connected to the xpander platform. Get instant feedback, set breakpoints, and iterate quickly without deploying.

Overview

Hot Reloading

Code changes apply instantly without restart

Full Integration

Access all platform tools and connectors locally

Breakpoints

Standard debugger support (pdb, IDE debuggers)

Live Logs

Real-time logging with configurable verbosity

Quick Start

1. Install CLI

pip install xpander-sdk

2. Authenticate

xpander login

3. Start Debug Server

xpander dev

4. Connect Your Agent

from xpander_sdk import Backend
from agno.agent import Agent

# Local mode automatically detected
backend = Backend()
agent = Agent(**backend.get_args())

# Run locally with platform tools
agent.print_response("Check my calendar for today")

Development Modes

Interactive Mode

Run single prompts and see results:
xpander dev --interactive
xpander> What meetings do I have today?
[Tool: google-calendar-list] Fetching events...
[Tool: google-calendar-list] Found 3 events

You have 3 meetings today:
- 10:00 AM: Team standup
- 2:00 PM: Product review
- 4:00 PM: 1:1 with manager

xpander>

Watch Mode

Auto-reload on file changes:
xpander dev --watch
Watching for changes in ./src/**/*.py
[12:34:56] Reloading agent...
[12:34:57] Agent ready

Server Mode

Run a local API server:
xpander dev --server --port 8000
# Test with curl
curl -X POST http://localhost:8000/invoke \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Hello!"}'

Debugging Techniques

from xpander_sdk import Backend
import logging

# Enable verbose logging
logging.basicConfig(level=logging.DEBUG)

backend = Backend(log_level=logging.DEBUG)

Python Debugger (pdb)

from xpander_sdk import Backend
from agno.agent import Agent
import pdb

backend = Backend()
agent = Agent(**backend.get_args())

# Set breakpoint
pdb.set_trace()

response = agent.run("Debug this request")

IDE Debugging

VS Code

// .vscode/launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug Agent",
      "type": "python",
      "request": "launch",
      "program": "${workspaceFolder}/agent.py",
      "env": {
        "XPANDER_DEBUG": "true"
      }
    }
  ]
}

PyCharm

  1. Right-click agent.py → Debug
  2. Breakpoints work automatically
  3. Inspect variables in debugger panel

Local Tool Testing

Test tool calls without hitting production:

Mock Responses

from xpander_sdk import Backend
from xpander_sdk.testing import MockTool

backend = Backend()

# Mock specific tool
backend.mock_tool(
    "github-issues-list",
    response={
        "issues": [
            {"id": 1, "title": "Test issue", "state": "open"}
        ]
    }
)

# Agent uses mocked response
agent = Agent(**backend.get_args())
agent.run("List GitHub issues")

Record & Replay

from xpander_sdk import Backend

# Record mode - save real responses
backend = Backend(record_tools=True)
agent = Agent(**backend.get_args())
agent.run("List GitHub issues")  # Saves response

# Replay mode - use recorded responses
backend = Backend(replay_tools=True)
agent = Agent(**backend.get_args())
agent.run("List GitHub issues")  # Uses saved response

Environment Configuration

Local Environment Variables

# .env.local
XPANDER_API_KEY=your-api-key
XPANDER_AGENT_ID=agent-123
XPANDER_DEBUG=true
XPANDER_LOG_LEVEL=DEBUG
from dotenv import load_dotenv
load_dotenv('.env.local')

from xpander_sdk import Backend
backend = Backend()  # Reads from env

Override Configuration

backend = Backend(
    # Override agent configuration locally
    model="gpt-4",
    temperature=0.5,
    max_tokens=2000,

    # Local-only settings
    debug=True,
    timeout=60
)

Testing

Unit Tests

import pytest
from xpander_sdk import Backend
from xpander_sdk.testing import MockBackend

def test_agent_response():
    backend = MockBackend()
    backend.mock_tool("weather-api", {"temp": 72, "condition": "sunny"})

    agent = Agent(**backend.get_args())
    response = agent.run("What's the weather?")

    assert "72" in response.content
    assert "sunny" in response.content.lower()

Integration Tests

import pytest
from xpander_sdk import Backend

@pytest.fixture
def backend():
    return Backend(
        environment="testing",
        record_tools=True
    )

def test_full_workflow(backend):
    agent = Agent(**backend.get_args())

    # Test complete workflow
    response = agent.run("Create a GitHub issue for bug #123")

    assert response.status == "success"
    assert "issue created" in response.content.lower()

Troubleshooting

Common Issues

Ensure you’re authenticated:
xpander login
xpander whoami  # Verify connection
Check agent has tools configured:
xpander agent info --tools
Enable local caching:
backend = Backend(cache_tools=True)

Debug Logs

# Maximum verbosity
XPANDER_LOG_LEVEL=TRACE xpander dev

# Log to file
xpander dev --log-file debug.log