Table of Contents

Interface IDelegationRouter

Namespace
LMKit.Agents.Delegation
Assembly
LM-Kit.NET.dll

Defines a contract for routing delegation requests to appropriate agents.

Implementations can provide custom logic for selecting which agent should handle a delegation request based on task content, agent capabilities, or other criteria.

public interface IDelegationRouter

Examples

A custom router that picks the agent whose persona contains a keyword:

using LMKit.Agents;
using LMKit.Agents.Delegation;

public sealed class KeywordRouter : IDelegationRouter { public Task<Agent> SelectAgentAsync(DelegationRequest request, AgentRegistry agents, CancellationToken ct) { foreach (var agent in agents) { if (request.Task.Contains(agent.Identity?.Persona ?? string.Empty, StringComparison.OrdinalIgnoreCase)) return Task.FromResult(agent); } return Task.FromResult<Agent>(null); }

public bool CanHandle(Agent agent, DelegationRequest request) =>
    agent.Identity != null;

}

Methods

CanHandle(Agent, DelegationRequest)

Determines if the given agent can handle the specified request.

SelectAgentAsync(DelegationRequest, AgentRegistry, CancellationToken)

Selects the most appropriate agent to handle the given request.

Share