An interactive debugging demo for AAIF (AI Agent Infrastructure Forum)
Learn to debug AI agents using distributed tracing. This demo showcases:
- MCP (Model Context Protocol) - Agent-to-tool communication
- A2A (Agent-to-Agent) - Agent delegation to specialized agents
- OpenTelemetry + Jaeger - Infrastructure tracing
- Langfuse - LLM observability
A customer asks: "Where is my order?"
Scenario 1: Slow Query Bug (LOGISTICS_BUGGY=true)
- All traces are GREEN β - no errors
- But response takes 25+ seconds
- Use Jaeger to find the slow span in the Logistics Agent
- Discover:
logistics.calculate_etahas a 15-second delay (N+1 query bug)
Scenario 2: Fixed (LOGISTICS_BUGGY=false)
- Same query, response in ~10 seconds
- Traces show fast spans across all services
# Clone and start
git clone https://github.com/Paranitharan1110/aaif-agent-demo.git
cd marina-mystery
# Set your OpenAI API key
echo "OPENAI_API_KEY=sk-your-key" > .env
# Start with the buggy scenario (for demo)
A2A_ENABLED=true LOGISTICS_BUGGY=true docker compose up -d
# Wait for services to be ready (~30 seconds)
docker compose ps
# Open the demo
open http://localhost:3333 # Marina Eats UI
open http://localhost:16686 # Jaeger (infrastructure traces)
open http://localhost:3100 # Langfuse (LLM observability)# Buggy scenario (15-second delay in Logistics Agent)
A2A_ENABLED=true LOGISTICS_BUGGY=true docker compose up -d
# Fixed scenario (fast response)
A2A_ENABLED=true LOGISTICS_BUGGY=false docker compose up -d
# View agent capabilities
curl http://localhost:3333/api/capabilities | jq
# View Logistics Agent's A2A card
curl http://localhost:8003/.well-known/agent.json | jq ββββββββββββββββββββ
β LOGISTICS AGENT β
β (A2A) β
β :8003 β
ββββββββββ²ββββββββββ
β A2A :3001
ββββββββββββββββ ββββββββββββββββ βββββββββββββββββ β ββββββββββββββββ ββββββββββββββββ
β UI ββββββΆβ MARINA ββββββΆβ AGENTGATEWAY ββββ΄ββΆβ MCP SERVER ββββββΆβ DELIVERY β
β :3333 β β AGENT β β MCP :3000 β β :8002 β β SERVICE β
β β β β β Admin :4000 β β β β :8001 β
ββββββββββββββββ ββββββββββββββββ βββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β β β β
βΌ βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β OTEL COLLECTOR :4317 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββ΄βββββββββββββββββββ
βΌ βΌ
βββββββββββββββ βββββββββββββββ
β JAEGER β β LANGFUSE β
β :16686 β β :3100 β
β Infra view β β Agent view β
βββββββββββββββ βββββββββββββββ
The Marina Agent can delegate specialized logistics questions to the Logistics Agent via the A2A protocol:
- Marina Agent - Main customer support agent
- Logistics Agent - Specializes in delivery logistics, courier availability, ETA calculations
A2A calls flow through AgentGateway on port 3001, providing full observability of agent-to-agent communication.
- Open http://localhost:3333
- Ask: "Where is my order?"
- Notice: Response takes 25+ seconds (slow!)
- Open http://localhost:16686
- Select Service:
logistics-agent - Click "Find Traces"
- Click on the most recent trace
- Finding:
logistics.calculate_etaspan takes 15 seconds! - Click on the span, check Tags:
logistics.bug_type: "slow_query"logistics.query_time_ms: 15000
# Restart with bug disabled
A2A_ENABLED=true LOGISTICS_BUGGY=false docker compose up -d logistics-agent- Ask the same question again
- Response now takes ~10 seconds
- In Jaeger,
logistics.calculate_etanow shows <100ms
All traces were GREEN (no errors), but the latency revealed the bug. This is why observability matters - you can't find performance issues from logs alone.
| Scenario | Command | Behavior |
|---|---|---|
| Buggy (slow query) | LOGISTICS_BUGGY=true docker compose up -d |
15-second delay in Logistics Agent |
| Fixed | LOGISTICS_BUGGY=false docker compose up -d |
Fast response, no delays |
| A2A Disabled | A2A_ENABLED=false docker compose up -d |
Marina Agent has no A2A tools |
| A2A Enabled | A2A_ENABLED=true docker compose up -d |
Marina Agent can call Logistics Agent |
| Tool | URL | Purpose |
|---|---|---|
| Jaeger | http://localhost:16686 | Distributed tracing - see the full request journey |
| Langfuse | http://localhost:3100 | LLM observability - see model calls, tool usage, tokens, costs |
| AgentGateway | http://localhost:4001/stats/prometheus | MCP + A2A proxy metrics |
Jaeger (Infrastructure View):
- End-to-end traces across all services
- Service dependency graph:
marina-agentβmcp-serverβdelivery-serviceβlogistics-agent - Latency breakdown per service
- HTTP status codes and errors
Langfuse (Agent/LLM View):
- LLM reasoning and tool call decisions
- Token usage (prompt/completion/total)
- Model latency per generation
- Completeness scores
- Input/output for each tool call
| Layer | Question Answered |
|---|---|
| Jaeger | "What services were called? How long did each take?" |
| Langfuse | "Why did the agent call those services? What was it thinking?" |
- MCP calls (port 3000): Marina Agent β MCP Server tool calls
- A2A calls (port 3001): Marina Agent β Logistics Agent delegation
- End-to-end traces: Full journey from UI to backend services
-
An API can be correct for software and still be poor for an agent
{"status": "PENDING"}is valid JSON, but doesn't help the agent decide
-
Observability reveals semantic issues, not just errors
- No errors in logs, but traces show repeated tool calls
-
The investigation method matters
- "What does the evidence say?" vs "What do you think is broken?"
Copy .env.example to .env to customize:
cp .env.example .envKey settings:
OPENAI_API_KEY: Your OpenAI API key (required)A2A_ENABLED: Enable A2A tools (true/false, default:true)LOGISTICS_BUGGY: Enable slow query bug (true/false, default:false)LLM_MODEL: Model to use (default:gpt-4o-mini)
# Rebuild after code changes
docker compose up -d --build
# View logs
docker compose logs -f agent
# Stop everything
docker compose down
# Clean up (including volumes)
docker compose down -v| Endpoint | Description |
|---|---|
GET /api/capabilities |
Show Marina Agent's tools and config |
POST /api/chat |
Send a message to the agent |
GET /health |
Health check |
| Endpoint (Logistics Agent) | Description |
|---|---|
GET /.well-known/agent.json |
A2A Agent Card (capabilities) |
POST /a2a/tasks |
Execute A2A task |
Apache 2.0 - See LICENSE
Built for AAIF 2025 | Architecture