Property this
this[string]
Gets the agent registered with the specified name.
public Agent this[string name] { get; }
Parameters
namestringThe name of the agent to retrieve. Case-sensitive.
Property Value
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
nameis registered.