Class AgentRouter
Routes inbound channel messages to agents in the agent pool. Supports routing strategies: round-robin, dedicated (1:1 channel:agent), or tag-based.
public sealed class AgentRouter
- Inheritance
-
AgentRouter
- Inherited Members
Constructors
AgentRouter(AgentPoolService, IChannelRegistry, IEventBus, ILogger<AgentRouter>)
public AgentRouter(AgentPoolService pool, IChannelRegistry channels, IEventBus events, ILogger<AgentRouter> logger)
Parameters
poolAgentPoolServicechannelsIChannelRegistryeventsIEventBusloggerILogger<AgentRouter>
Fields
ChannelTypeMetadataKey
public const string ChannelTypeMetadataKey = "gateway.channelType"
Field Value
RouteKeyMetadataKey
public const string RouteKeyMetadataKey = "gateway.routeKey"
Field Value
Methods
GetAgentForChannel(string)
Get the agent ID currently mapped to a channel, or null.
public string? GetAgentForChannel(string channelId)
Parameters
channelIdstring
Returns
GetMappings()
Get all current channel-to-agent mappings.
public IReadOnlyDictionary<string, string> GetMappings()
Returns
MapChannel(string, string)
Map a channel to a specific agent ID.
public void MapChannel(string channelId, string agentId)
Parameters
RouteAsync(ChannelMessage, IChannel?, CancellationToken)
Route an inbound message to the mapped agent and send the response via the provided source channel.
public Task<string?> RouteAsync(ChannelMessage message, IChannel? sourceChannel, CancellationToken ct = default)
Parameters
messageChannelMessagesourceChannelIChannelctCancellationToken
Returns
RouteAsync(ChannelMessage, CancellationToken)
Route an inbound message to the mapped agent and return the response.
public Task<string?> RouteAsync(ChannelMessage message, CancellationToken ct = default)
Parameters
messageChannelMessagectCancellationToken