Class AgentExecutionOptions
Configuration options for agent execution, providing fine-grained control over context sizing, iteration limits, timeouts, and output constraints.
public sealed class AgentExecutionOptions
- Inheritance
-
AgentExecutionOptions
- Inherited Members
Examples
Using execution options for different scenarios:
using LMKit.Model;
using LMKit.Agents;
using var model = LM.LoadFromModelID("qwen3:8b");
var agent = new Agent(model);
// Quick response with timeout
var quickOptions = new AgentExecutionOptions
{
Timeout = TimeSpan.FromSeconds(10),
MaxCompletionTokens = 200
};
var quickResult = agent.Run("Give a one-sentence summary of AI.", quickOptions);
// Deep research with more iterations
var researchOptions = new AgentExecutionOptions
{
MaxIterations = 20,
Timeout = TimeSpan.FromMinutes(5)
};
var researchResult = agent.Run("Analyze the pros and cons of microservices.", researchOptions);
Remarks
Execution options allow you to customize how an agent processes a specific task without modifying the agent's base configuration. Options can override agent defaults for individual executions.
Common Use Cases
- Set timeouts for user-facing applications.
- Limit token output for summary tasks.
- Increase iterations for complex research tasks.
- Clear history for stateless interactions.
Properties
- ApprovalTimeout
Gets or sets how long a run stopped for approvals waits before ApprovalTimeoutAction applies (ApprovalDeadlineUtc). Null sets no deadline.
- ApprovalTimeoutAction
Gets or sets what happens to approvals nobody decided before the deadline.
- ClearHistoryBeforeExecution
Gets or sets a value indicating whether to clear conversation history before execution.
- ContextSize
Gets or sets the context size for the conversation.
- Default
Gets a fresh default execution options instance.
- DeferToolApprovals
Gets or sets whether a tool call that needs approval stops the run (AwaitingApproval) instead of raising the synchronous ToolApprovalRequired event, so the decision can come later, from anywhere, and survive a restart.
- HandoffHandler
Gets or sets the handler told when a run hands the conversation to a person (WithHumanHandoff()). Null: the hand-off is on the result only.
- MaxCompletionTokens
Gets or sets the maximum number of tokens for completion per turn.
- MaxIterations
Gets or sets the maximum number of iterations allowed during execution.
- ReasoningLevel
Gets or sets the model-internal reasoning level for this execution.
- RunId
Gets or sets the run's identifier, carried on the result, on the run's events and spans and in its AgentRunState. Null generates one. A resumed run keeps the identifier of its state.
- RunMetadata
Gets or sets host data stored with the run's state (Metadata): an owner, a tenant, an agent revision.
agentnames the run's agent (Agent);owneris what ListAsync(string, CancellationToken) filters on. Null stores none.
- RunStore
Gets or sets where the run's checkpoints go: after every tool result, before every side-effecting call, when the run stops and when it ends. Null keeps no checkpoint; a run that stops for a decision still returns its state on RunState.
- SamplingMode
Gets or sets the token sampling strategy for this execution.
- Timeout
Gets or sets the maximum time allowed for execution.
- ToolArgumentRedactor
Gets or sets the hook that redacts a call's arguments before a tool activity records them: given the tool's name and the arguments, it returns what may be traced. Null records them as they are.
- TraceToolArguments
Gets or sets whether tool activities (TagToolArguments) carry the call's arguments. Off by default: arguments may hold personal or secret data.
Methods
- Clone()
Creates a copy of this options instance.