Class RouterOrchestrator
- Namespace
- LMKit.Agents.Orchestration
- Assembly
- LM-Kit.NET.dll
Orchestrator that routes the input to the most appropriate single agent.
Uses a routing function or agent to select which specialist agent should handle the request, then executes only that agent.
public sealed class RouterOrchestrator : OrchestratorBase, IOrchestrator
- Inheritance
-
RouterOrchestrator
- Implements
- Inherited Members
Examples
var router = new RouterOrchestrator()
.AddRoute("code", codeAgent)
.AddRoute("data", dataAgent)
.AddRoute("general", generalAgent)
.WithRoutingFunction((input, agents) => {
if (input.Contains("code")) return "code";
if (input.Contains("data")) return "data";
return "general";
});
var result = await router.ExecuteAsync("Write code to sort a list");
Remarks
Use Cases
- Intent-based routing to specialized agents
- Load distribution across equivalent agents
- Skill-based task assignment
Constructors
- RouterOrchestrator()
Initializes a new instance of the RouterOrchestrator class.
Properties
- Name
Gets the name of this orchestrator.
Methods
- AddRoute(string, Agent)
Adds a named route to an agent.
- ExecuteCoreAsync(OrchestrationContext, OrchestrationOptions, CancellationToken)
Executes the routing and selected agent.
- WithDefaultRoute(string)
Sets the default route to use when no match is found.
- WithRouterAgent(Agent)
Sets an agent-based router that decides which route to take.
The router agent should output the name of the route to use.
- WithRoutingFunction(Func<string, IReadOnlyDictionary<string, Agent>, string>)
Sets a function-based router.