← Back to Writings
SYS.DOC
· Updated:

Architecting Cyclic Multi-Agent Systems with LangGraph & 3072d Vector RAG

Production patterns for deterministic state machines, sub-280ms p95 hybrid retrieval over MongoDB Atlas Vector Search, and fault-tolerant tool execution.

Architecting Cyclic Multi-Agent Systems with LangGraph & 3072d Vector RAG

When moving conversational AI systems from prototype chains to high-concurrency production workloads in the airline industry (Suite Aerya), linear DAG pipelines fail under real user ambiguity. Passengers switch intents mid-flight, tool calls time out against legacy PSS APIs, and naive vector lookups hallucinate fare rules.

Here is the production blueprint we engineered to sustain 14.2k domain events/min with p95 < 280ms retrieval latency.

1. Cyclic State Machines over Linear Chains

Instead of unconstrained autonomous loops, we model every conversation turn as a typed LangGraph state machine with explicit supervisor routing and bounded retry edges:

  • Supervisor Router (Gemini 2.0): Classifies intent and extracts structured slot diffs in 12.1ms median latency.
  • Checkpoint Persistence: Every node transition checkpoints state into Redis + MongoDB, enabling zero-context-loss recovery across stateless Google Cloud Run instances.
  • Deterministic Guardrails: Tool outputs are validated via strict Zod/Pydantic schemas before state mutation; schema failures route to a specialized self-correction node rather than surfacing raw LLM errors.

Standard 1,536-dimension embeddings struggled with fine-grained multilingual fare regulations and baggage policy exceptions. Upgrading to 3,072-dimension embeddings on MongoDB Atlas Vector Search with pre-filtering by airline tenant ID and policy effective date yielded a 0.94 cosine recall benchmark while keeping vector query execution under 38.4ms p99.

3. Decoupling Side Effects via Redis Pub/Sub & Cloud Tasks

Agent nodes never block on slow downstream webhooks (WhatsApp, Instagram, airline CRM). State transitions emit domain events onto a Redis Pub/Sub Domain Event Bus, while Google Cloud Tasks manages exponential backoff, rate limiting, and dead-letter queues for guaranteed webhook delivery.

INTERACTIVE TELEMETRY SIMULATOR // SYS.BENCH

Edge Caching & Multi-Agent p95 Latency Simulator

613.4M evt/mo
14,200 evt/m
68%
Effective p95 Latency
110ms
vs 612ms unoptimized
LLM + Vector Compute Saved
$75,085/mo
3,072d embedding bypass
DO SQLite State Read
0.42ms
Zero network hop (Co-located)