Table of Contents

Property MaxIterations

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

MaxIterations

Gets or sets the maximum number of iterations allowed during a single task execution.

public int MaxIterations { get; set; }

Property Value

int

Examples

Configuring iteration limits:

using LMKit.Model;
using LMKit.Agents;

using var model = new LM("path/to/model.gguf");
var agent = new Agent(model);

// Allow more iterations for complex research tasks
agent.MaxIterations = 25;

// Or restrict iterations for simple Q&A
agent.MaxIterations = 3;

Remarks

Iterations count tool-call and reasoning cycles. This limit prevents infinite loops when the agent repeatedly calls tools or cannot reach a conclusion. The default value is 10.

Increase this value for complex tasks that require many tool calls. Decrease it for simple tasks or to reduce latency.

Exceptions

ArgumentOutOfRangeException

Thrown when setting a value less than 1.