Table of Contents

Method EnableDelegation

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

EnableDelegation()

Creates and registers a DelegateTool for this agent.

public DelegateTool EnableDelegation()

Returns

DelegateTool

The created tool, or null if no delegates are configured.

Examples

Enabling delegation for a coordinator agent:

using LMKit.Model;
using LMKit.Agents;

using var model = new LM("path/to/model.gguf");

// Create specialist agents
var codeAgent = new Agent(
    new AgentIdentity("Coder", "Write clean, efficient code."),
    model
);

var reviewAgent = new Agent(
    new AgentIdentity("Reviewer", "Review code for bugs and improvements."),
    model
);

// Create coordinator with delegation
var coordinator = new Agent(model);
coordinator.Identity = new AgentIdentity(
    "Project Lead",
    "Coordinate coding and review tasks."
);

coordinator.Delegates = new AgentRegistry();
coordinator.Delegates.Register("coder", codeAgent);
coordinator.Delegates.Register("reviewer", reviewAgent);

// Enable the delegation tool
var delegateTool = coordinator.EnableDelegation();
if (delegateTool != null)
{
    Console.WriteLine("Delegation enabled!");
}

// Now the coordinator can delegate tasks
var result = await coordinator.RunAsync(
    "Write a function to sort a list, then review it."
);

Remarks

The delegation tool allows this agent to hand off subtasks to agents in its Delegates registry. The tool is automatically registered in the agent's tool registry.

Call this method after configuring the Delegates registry.