Agent Routing Logic

Agent routing logic allows you to define specific conditions that determine when a particular agent should be selected, providing fine-grained control over your multi-agent system's behavior.

What is Agent Routing?

Agent routing is an optional configuration that extends the supervisor's decision-making with explicit rules about when to use specific agents. It's particularly useful for ensuring conversation continuity or handling specialized paths.

Why Use Custom Routing Logic?

Custom routing logic helps:

  • Ensure conversation continuity with specific agents
  • Handle specialized conversation paths
  • Create persistent agent selection for specific topics
  • Override default routing behavior for edge cases

How to Configure Custom Agent Routing

  1. In the supervisor settings, locate the "Agent Routing" section (it may appear as a JSON input field)
  2. Create a JSON object where keys are your agent names and values are routing conditions
  3. Ensure agent names match exactly with your actual agent names (be careful with spaces)
  4. Write clear conditions that specify when the agent should be maintained
  5. Save your changes

Example routing configuration:

[
  {
    "message": "Stick to {AGENT_NAME} if it has already been started until user asks to exit from it once started. Only exit from the DEEPDIVE agent if user explicitly asks to exit from it. Otherwise, keep the conversation going with the {AGENT_NAME} agent.",
    "agentName": "DEEPDIVE",
    "enabled": true
  }
]

This tells the supervisor to maintain the "deepdive" agent once selected, unless the user explicitly requests otherwise.

Note: Agent names in the routing configuration must match exactly with the actual agent names in your system. Spaces in agent names may cause issues, so be careful when configuring routing.

How to Test Your Routing Logic

  1. Save your routing configuration
  2. Use the preview or test interface to start a conversation
  3. Try different user inputs that should trigger different agents
  4. Verify that the expected agent is selected each time
  5. Test edge cases, particularly transitions between agents

Troubleshooting Routing Issues

  1. Check that agent names in your routing configuration exactly match your actual agent names
  2. Ensure your JSON syntax is correct (no missing commas, brackets, or quotes)
  3. Verify that your routing conditions are clear and don't contradict each other
  4. Review the supervisor logs (if available) to see why certain routing decisions were made
  5. Make incremental changes and test after each change to isolate issues

Example Use Cases

Persistent Deep Dive Agent

[
  {
    "message": "Stick to {AGENT_NAME} if it has already been started until user asks to exit from it once started. Only exit from the DEEPDIVE agent if user explicitly asks to exit from it. Otherwise, keep the conversation going with the {AGENT_NAME} agent.",
    "agentName": "DEEPDIVE",
    "enabled": true
  }
]

Technical Support Escalation


[
  {
    "message": "Once technical troubleshooting has begun, continue with this agent until the issue is resolved.",
    "agentName": "techsupport",
    "enabled": true
  }
]





## Next Steps

After configuring your agent routing logic, you'll want to create effective [agent-specific prompts](agent-specific-prompting.md) for each of your agents.