Method WithInstruction
WithInstruction(string)
Creates a new AgentIdentity with the specified instruction, preserving the current persona.
public AgentIdentity WithInstruction(string instruction)
Parameters
instructionstringThe new instruction to use.
Returns
- AgentIdentity
A new AgentIdentity instance with the updated instruction.
Examples
Creating variants with different instructions:
using LMKit.Agents;
var baseIdentity = new AgentIdentity(
"Code Assistant",
"Help with general programming questions."
);
// Create specialized variants
var pythonIdentity = baseIdentity.WithInstruction(
"Help with Python programming. Use Python 3.x syntax."
);
var csharpIdentity = baseIdentity.WithInstruction(
"Help with C# programming. Follow .NET conventions."
);
// All share the same persona
Console.WriteLine(baseIdentity.Persona == pythonIdentity.Persona); // True
Remarks
This method enables immutable updates. The original instance remains unchanged.