When your agents fail, xDebug tells you why
Developer tools for debugging AI agent interactions. Capture, trace, and analyze execution flow in AI agent systems with error explanation, performance profiling, message flow tracing, and session debugging.
Agent developers spend 60% of their time debugging opaque errors
AI agents fail in production with cryptic errors. Multi-agent workflows hide bottlenecks. Message flows span multiple services. Execution context disappears across async operations.
Traditional debugging tools were not built for AI agent systems. Logs are scattered across services. Stack traces point to framework internals, not your code. Performance bottlenecks hide in distributed workflows. Error messages expose implementation details without explaining root causes.
Error explainer. Profiler. Message tracer. CLI tools.
xDebug provides developer tools specifically designed for AI agent systems built with the Private.Me SDK. Convert cryptic errors into actionable fixes. Identify bottlenecks in multi-agent workflows. Visualize agent-to-agent communication. Capture full execution context across async operations.
5 Debug Capabilities
3-Step Integration
1. Install Package
npm install @private.me/xdebug
2. Error Explainer (Basic)
import { explainError } from '@private.me/xdebug'; try { await agent.send({ to, payload }); } catch (error) { const explanation = await explainError(error); console.error(explanation.message); console.log('Suggested fixes:', explanation.remediation); }
3. Session Profiler (Advanced)
import { Profiler } from '@private.me/xdebug'; const profiler = new Profiler({ sessionId: 'debug-001' }); profiler.start(); await agent.send({ to, payload }); const report = profiler.stop(); console.log(`Total duration: ${report.duration}ms`); console.log(`Events captured: ${report.events.length}`);
Live Debug Tracing
Performance Profiling
CLI Tools
Live watch mode with real-time metrics for your codebase. Track agent.call() patterns, error rates, latency, and recent errors automatically.
Dev Command - Live Watch Mode
# Watch current directory xdebug dev # Watch specific directory xdebug dev --path ./src # Enable verbose logging xdebug dev --verbose # Custom polling interval xdebug dev --interval 500
Metrics Displayed
- Total agent.call() count across all files
- Error count (calls within try/catch blocks)
- Error rate percentage
- Average latency (extracted from timing patterns)
- Recent errors with timestamps and file locations
Real-World Scenarios
Production Error Diagnosis
Production agent fails with cryptic error. Use explainError() to convert the error into actionable debug information with error codes, human-readable descriptions, and suggested remediation steps.
import { explainError, ErrorDetail } from '@private.me/xdebug'; try { await agent.send({ to: 'did:key:z6Mk...', payload: sensitiveData }); } catch (error) { const detail: ErrorDetail = await explainError(error, { includeContext: true, suggestRemediation: true }); // Log for ops team logger.error({ code: detail.code, type: detail.type, message: detail.message, remediation: detail.remediation, timestamp: detail.timestamp }); }
Performance Optimization
Multi-agent workflow running slowly. Use the Profiler to capture performance metrics, identify bottlenecks, and analyze slow operations.
const profiler = new Profiler({ context: { sessionId: crypto.randomUUID(), agentId: agent.did, environment: 'production' } }); profiler.start(); await processLargeDataset(agent, dataset); const report = profiler.stop(); // Identify slow operations const slowEvents = report.events.filter(e => e.duration > 1000); console.log('Bottlenecks:', slowEvents);
Multi-Agent Communication Debugging
Distributed workflow with multiple agents. Use MessageTracer to track agent-to-agent communication, analyze message flows, and identify failed messages.
import { MessageTracer } from '@private.me/xdebug'; const tracer = new MessageTracer(); // Attach to all agents in system tracer.attach(coordinatorAgent); tracer.attach(workerAgent1); tracer.attach(workerAgent2); // Run distributed workflow await coordinatorAgent.send({ to: workerAgent1.did, payload: task1 }); await coordinatorAgent.send({ to: workerAgent2.did, payload: task2 }); // Analyze communication patterns const flows = tracer.getFlows(); const failedMessages = flows.filter(f => f.status === 'failed'); const avgLatency = flows.reduce((sum, f) => sum + (f.latency || 0), 0) / flows.length; console.log(`Failed: ${failedMessages.length}/${flows.length}`);
Session Replay
Agent execution fails intermittently. Use session recording to capture full execution context and export for later analysis.
import { DebugSession, exportSession } from '@private.me/xdebug'; const profiler = new Profiler({ sessionId: 'incident-20260427' }); profiler.start(); try { await runComplexWorkflow(agent); } catch (error) { const session = profiler.getSession(); // Export for later analysis await exportSession(session, { format: 'json', includeStackTraces: true, includeContext: true, path: './debug-sessions/incident-20260427.json' }); }
Core APIs
Types
interface ErrorDetail { code: string; // Error code (e.g., SIGNATURE_INVALID) message: string; // Human-readable description type: string; // Category (auth, network, crypto, validation) stack?: string; // Stack trace if available timestamp: string; // When error occurred remediation: string[]; // Suggested fix steps } interface DebugEvent { id: string; timestamp: string; level: DebugLevel; category: string; message: string; data?: Record<string, unknown>; stack?: string; agentId?: string; sessionId?: string; } interface DebugSession { id: string; context: DebugContext; startedAt: string; endedAt?: string; events: DebugEvent[]; status: 'active' | 'completed' | 'failed' | 'timeout'; duration?: number; }
Framework Integration
xDebug integrates with popular AI agent frameworks. Works with LangChain, AutoGPT, CrewAI, and any system built with the Private.Me SDK.
LangChain Integration
Wrap LangChain agents with xDebug profiling and error explanation. Automatically capture execution events and convert errors.
AutoGPT Integration
Attach MessageTracer to AutoGPT agents for message flow visualization. Track communication between autonomous agents.
CrewAI Integration
Use the Profiler to identify bottlenecks in CrewAI multi-agent workflows. Export sessions for team debugging.
Common Issues
Issue: "Cannot attach tracer to agent"
Cause: Agent instance not compatible with tracer.
// Ensure agent is from @private.me/xlink import { Agent } from '@private.me/xlink'; const agent = await Agent.quickstart(); tracer.attach(agent); // Now works
Issue: "Session export too large"
Cause: Too many events or large payloads.
// Apply filters before export await exportSession(session, { format: 'json', filter: { level: 'error', // Only errors timeRange: { start: '2026-04-27T10:00:00Z', end: '2026-04-27T11:00:00Z' } }, includePayloads: false // Exclude payloads });
Issue: "High memory usage during profiling"
Cause: Long-running sessions accumulating events.
// Stop profiler periodically and export setInterval(() => { const report = profiler.stop(); exportSession(report, { format: 'jsonl', path: './debug.jsonl' }); profiler.start(); // Resume profiling }, 60000); // Every 60 seconds
Free for All Developers
xDebug is a free developer tool. No credit card required, no trial period, no subscription. Install and start debugging immediately.
pnpm add @private.me/xdebug