Building Multi-Agent Systems the A2A Way: A Hands-On Project with LangGraph

 A claims processing system with three services that communicate using Google's A2A (Agent-to-Agent) protocol over JSON-RPC 2.0:

🔹 A Gateway that handles auth, guardrails, and routing 🔹 A Claims Agent that validates claims and checks for fraud 🔹 A Policy Agent that answers coverage and benefits questions

Each agent publishes its own capabilities at a standard /.well-known/agent-card.json endpoint — meaning any A2A-compatible client can discover what it does without me hard-coding anything. Same pattern you'd use to plug into a partner agent in real production.

🛠️ The stack

✅ FastAPI + Pydantic for the JSON-RPC layer ✅ LangGraph for stateful agent reasoning (StateGraph + checkpointing) ✅ MCP (Model Context Protocol) for clean tool abstraction ✅ Anthropic Claude — using Haiku for routing, Sonnet for reasoning, Opus reserved for hard cases ✅ LangSmith for end-to-end observability ✅ Custom guardrails for PII detection and prompt injection

🔍 Why this combo clicks

Most agent tutorials show you a single agent calling some tools. That's fine for demos. But real systems need symmetric communication (any agent calling any other), discoverability (no hard-coded contracts), auditability (especially in regulated domains), and composability (swap an agent without rewriting the orchestrator).

A2A + JSON-RPC handles communication between agents. LangGraph handles reasoning inside each agent. Clean separation. Each piece does what it's good at.

📊 The LangSmith moment

This is where it got fun. Once I wired up tracing, every request became a fully visible tree — LangGraph nodes, every LLM call with token counts and latency, every tool invocation with full inputs and outputs.

A Look up claim CLM-1003 request showed up as a 16.39s trace: call_llm → claim_lookup tool → call_llm → final synthesis. I could literally watch the model reason.



💡 Three things that surprised me

JSON-RPC 2.0 is underrated. It's old, boring, and exactly what multi-agent systems need. No need to reinvent the wheel.

MCP makes tools portable. I wrote my tools once. Today they plug into Claude's tool-use API. Tomorrow they plug into any MCP server with zero code change.

Three-tier model routing is a massive cost lever. Haiku for routing, Sonnet for reasoning, Opus only when needed. Easily a 5–10× difference in spend.

🔗 Code is open

Full repo here — feel free to fork, break, learn from, or roast my design choices: 👉 https://github.com/sudeepkrishnan87/a2a-insurance-system


Comments

Popular posts from this blog

SOLID Principle (Quick Read)

Building a Smart Holiday Booking System with Agent-to-Agent Communication

Apache kafka using kraft