Method WithDelegationEnabled
WithDelegationEnabled()
Enables automatic registration of the delegate tool when the agent is built.
public AgentBuilder WithDelegationEnabled()
Returns
- AgentBuilder
This builder instance for method chaining.
Examples
Building a coordinator agent with automatic delegation:
using LMKit.Model;
using LMKit.Agents;
using var model = new LM("path/to/model.gguf");
var coordinator = new AgentBuilder()
.WithModel(model)
.WithIdentity(
persona: "Team Coordinator",
instruction: "Analyze tasks and delegate to the appropriate specialist."
)
.WithPlanning(PlanningStrategy.ReAct)
.WithDelegates(delegates =>
{
delegates.Register("writer", new Agent(
new AgentIdentity("Writer", "Write content."),
model
));
delegates.Register("editor", new Agent(
new AgentIdentity("Editor", "Edit and proofread content."),
model
));
})
.WithDelegationEnabled()
.Build();
var result = await coordinator.RunAsync(
"Write a blog post about AI, then edit it for clarity."
);
Remarks
When enabled, a DelegateTool is automatically registered if the agent has delegates configured. This allows the agent to decide when to delegate tasks to specialist agents.
Call this after configuring delegates with WithDelegates(AgentRegistry) or WithDelegates(Action<AgentRegistry>).