Table of Contents

Method WithPersona

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

WithPersona(string)

Creates a new AgentIdentity with the specified persona, preserving the current instruction.

public AgentIdentity WithPersona(string persona)

Parameters

persona string

The new persona to use.

Returns

AgentIdentity

A new AgentIdentity instance with the updated persona.

Examples

Creating a variant with a different persona:

using LMKit.Agents;

var baseIdentity = new AgentIdentity(
    "Technical Writer",
    "Write clear documentation with code examples."
);

// Create a variant for a different audience
var beginnerIdentity = baseIdentity.WithPersona("Technical Writer for Beginners");
var advancedIdentity = baseIdentity.WithPersona("Technical Writer for Experts");

// Original is unchanged
Console.WriteLine(baseIdentity.Persona);     // Technical Writer
Console.WriteLine(beginnerIdentity.Persona); // Technical Writer for Beginners
Console.WriteLine(advancedIdentity.Persona); // Technical Writer for Experts

// All share the same instruction
Console.WriteLine(baseIdentity.Instruction == beginnerIdentity.Instruction); // True

Remarks

This method enables immutable updates. The original instance remains unchanged.