supervisor pattern

Support bot — supervisor + RAG + ReAct + HITL

A production-grade customer support agent that routes between specialist sub-agents, retrieves docs, escalates to humans on refunds, and runs in 5 SDKs.

rustpythontypescriptgojava
View source on GitHub ↗

Highlights

  • Supervisor routes user messages to docs, orders, or escalation specialists.
  • Docs specialist is a RAG agent against your knowledge base.
  • Orders specialist is a ReAct agent with read/write tools.
  • Refunds ≥ $100 hit interrupt_before — wait for human approval.
  • Same logic in Rust, Python, TypeScript, Go and Java — identical responses.

What this shows

A real customer-support workflow you can deploy as-is. The supervisor reads the user message, picks a specialist (docs / orders / escalation), and routes. Specialists are sub-agents — independently testable, independently swappable. Refunds above $100 hit a human-in-the-loop interrupt that pauses the graph until an operator approves.

Architecture

              ┌──────────────┐
   user ────▶ │  Supervisor  │ ──▶ docs (RAG)
              └──────┬───────┘ ──▶ orders (ReAct)
                     │           ──▶ escalation (HITL)

              checkpoint + audit log

Key snippets

The Python supervisor is built with create_supervisor:

from agentmatic.prebuilt import create_react_agent, create_rag_agent, create_supervisor

docs = create_rag_agent(llm=OpenAI(), vectorstore=Qdrant.from_env())
orders = create_react_agent(llm=OpenAI(), tools=[get_order, update_order, refund])

supervisor = create_supervisor(
    llm=OpenAI(),
    agents={"docs": docs, "orders": orders},
    system_prompt="Route to docs for product questions, orders for account issues."
)

Refunds ≥ $100 trip a HITL interrupt:

supervisor = (Agent.builder("support")
    .agents({"docs": docs, "orders": orders})
    .interrupt_before_when(
        tool="refund",
        predicate=lambda args: args["amount"] >= 100,
    )
    .checkpoint(PostgresSaver.from_env())
    .build())

Multi-language parity

The TypeScript version uses the same supervisor pattern with napi-rs bindings:

import { createSupervisor, createReactAgent, createRagAgent } from '@agentmatic/core';
const supervisor = createSupervisor({
  llm: new OpenAI(),
  agents: { docs, orders },
});

Rust, Go and Java are similar — same primitives, same engine.

Ship your next agent in minutes, not weeks.

MIT licensed. Drop-in for LangGraph. Native SDKs in 5 languages. Battle-tested resilience primitives in the box.