Table of Contents

Method WithDelegates

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

WithDelegates(AgentRegistry)

Sets the registry of delegate agents for task handoff.

public AgentBuilder WithDelegates(AgentRegistry delegates)

Parameters

delegates AgentRegistry

The registry of agents available for delegation.

Returns

AgentBuilder

This builder instance for method chaining.

Examples

Setting up delegates:

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 code."), model);
var testAgent = new Agent(new AgentIdentity("Tester", "Write tests."), model);

// Create delegate registry
var delegates = new AgentRegistry();
delegates.Register("coder", codeAgent);
delegates.Register("tester", testAgent);

// Build coordinator with delegation
var coordinator = new AgentBuilder()
    .WithModel(model)
    .WithPersona("Tech Lead")
    .WithDelegates(delegates)
    .WithDelegationEnabled()
    .Build();

Remarks

Delegation enables multi-agent workflows where specialized agents handle specific subtasks.

WithDelegates(Action<AgentRegistry>)

Configures delegate agents using a setup action.

public AgentBuilder WithDelegates(Action<AgentRegistry> configure)

Parameters

configure Action<AgentRegistry>

An action to configure the delegate registry.

Returns

AgentBuilder

This builder instance for method chaining.

Examples

Configuring delegates inline:

using LMKit.Model;
using LMKit.Agents;

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

var coordinator = new AgentBuilder()
    .WithModel(model)
    .WithPersona("Project Manager")
    .WithInstruction("Coordinate tasks between team members.")
    .WithDelegates(delegates =>
    {
        delegates.Register("developer", new Agent(
            new AgentIdentity("Developer", "Implement features."),
            model
        ));
        delegates.Register("designer", new Agent(
            new AgentIdentity("Designer", "Create UI designs."),
            model
        ));
    })
    .WithDelegationEnabled()
    .Build();

Remarks

Creates a new registry if one hasn't been set. The action receives the registry for inline configuration.

Exceptions

ArgumentNullException

Thrown when configure is null.