Skip to content

About

aaif-agent-demo

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

2 Commits

Folders and files

Repository files navigation

Marina Mystery πŸ›πŸ”

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

The Demo Story

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_eta has 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

Quick Start

# 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)

Demo Commands

# 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

Architecture

                                                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                                    β”‚ 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  β”‚
                             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Agent-to-Agent (A2A) Communication

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.

The Investigation

Step 1: Trigger the Bug

  1. Open http://localhost:3333
  2. Ask: "Where is my order?"
  3. Notice: Response takes 25+ seconds (slow!)

Step 2: Find the Bug in Jaeger

  1. Open http://localhost:16686
  2. Select Service: logistics-agent
  3. Click "Find Traces"
  4. Click on the most recent trace
  5. Finding: logistics.calculate_eta span takes 15 seconds!
  6. Click on the span, check Tags:
    • logistics.bug_type: "slow_query"
    • logistics.query_time_ms: 15000

Step 3: Fix the Bug

# Restart with bug disabled
A2A_ENABLED=true LOGISTICS_BUGGY=false docker compose up -d logistics-agent

Step 4: Verify the Fix

  1. Ask the same question again
  2. Response now takes ~10 seconds
  3. In Jaeger, logistics.calculate_eta now shows <100ms

Key Insight

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.

Scenarios

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

Observability Stack

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

What You Can Observe

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

Two-Layer Observability

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?"

What You Can Observe

  • 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

Key Takeaways

  1. 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
  2. Observability reveals semantic issues, not just errors

    • No errors in logs, but traces show repeated tool calls
  3. The investigation method matters

    • "What does the evidence say?" vs "What do you think is broken?"

Configuration

Copy .env.example to .env to customize:

cp .env.example .env

Key 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)

Development

# 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

API Endpoints

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

License

Apache 2.0 - See LICENSE


Built for AAIF 2025 | Architecture

About

aaif-agent-demo

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages