Docs/Multi-Agent Routing

Multi-Agent Routing

When multiple agents are connected to the same channel, the gateway needs to decide which agent handles each incoming message. Hybrix provides three routing strategies to match different use cases.

Routing strategies

StrategyBest ForHow It Works
role-basedSpecialized teamsRoutes based on agent roles and message content analysis
round-robinLoad balancingDistributes messages evenly across available agents
intentSmart dispatchingUses a lightweight LLM classifier to detect intent and route accordingly

Role-based routing

The default strategy. The gateway inspects incoming messages for keywords and patterns associated with each agent's role. A message mentioning “code review” routes to a code-reviewer agent, while a general question routes to a general-assistant.

json
{
  "gateway": {
    "routing": "role-based",
    "fallbackAgent": "Atlas"
  }
}

If no role matches, the fallbackAgent handles the message. If no fallback is set, the first agent in the config is used.

Intent-based routing

The most intelligent strategy. A small, fast classifier model analyzes each message to determine the user's intent, then routes to the best-matched agent. This adds a small latency overhead (50-100ms) but provides the highest routing accuracy.

json
{
  "gateway": {
    "routing": "intent",
    "intentModel": "claude-haiku",
    "intents": {
      "code-help": ["Atlas"],
      "research": ["Scout"],
      "creative": ["Muse"],
      "default": ["Atlas"]
    }
  }
}
The intent classifier uses only the first 200 tokens of each message, keeping cost and latency minimal. Use a fast, cheap model like Haiku or GPT-4o-mini for the classifier.

Round-robin routing

Distributes messages evenly across agents. Useful when you have multiple identical agents for load balancing, or when you want to A/B test different models.

json
{
  "gateway": {
    "routing": "round-robin",
    "stickySession": true
  }
}

With stickySession enabled, once a user is routed to an agent, subsequent messages in the same session continue going to that agent for conversation continuity.