Table of Contents

Property this

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

this[string]

Gets the agent registered with the specified name.

public Agent this[string name] { get; }

Parameters

name string

The name of the agent to retrieve. Case-sensitive.

Property Value

Agent

The Agent registered with the specified name.

Examples

Example: Direct agent access by name

using LMKit.Agents;
using LMKit.Model;

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

var mathAgent = Agent.CreateBuilder()
    .WithModel(model)
    .WithPersona("Mathematician")
    .Build();
registry.Register("math", mathAgent);

// Direct access when agent is known to exist
Agent mathematician = registry["math"];
var result = await mathematician.RunAsync("What is the derivative of x^3?");
Console.WriteLine(result.Content);

Remarks

Use this indexer when you are certain the agent exists in the registry. For scenarios where the agent might not exist, use TryGet(string, out Agent) instead to avoid exceptions.

Name comparison is case-sensitive and uses ordinal string comparison.

Exceptions

KeyNotFoundException

Thrown when no agent with the specified name is registered.