Class AgentOptions
- Namespace
- Emissary
- Assembly
- Emissary.dll
Configuration for a ClaudeAgent.
public sealed class AgentOptions
- Inheritance
-
AgentOptions
- Inherited Members
Properties
ApiKey
API key override; null uses the ANTHROPIC_API_KEY environment variable.
public string? ApiKey { get; set; }
Property Value
ApprovalRequired
Human-in-the-loop gate: when set (and Mode is live), a tool call for which this returns true suspends the run durably instead of executing — the result carries a SuspendedRun to persist and later resume with ResumeAsync(SuspendedRun, bool, CancellationToken).
public Func<ToolDefinition, bool>? ApprovalRequired { get; set; }
Property Value
Authorizer
Decides which policy-gated tools ([AuthorizeTool]) the caller may use. Unauthorized tools are removed before prompt construction. With no authorizer, policy-gated tools are denied.
public IToolAuthorizer? Authorizer { get; set; }
Property Value
Compaction
Client-side context compaction, so long conversations survive past the context window. Disabled until TriggerInputTokens is set.
public CompactionOptions Compaction { get; }
Property Value
Effort
Optional effort budget; null uses the model default.
public EffortLevel? Effort { get; set; }
Property Value
Handoffs
Agents this one may transfer the conversation to. Each target becomes a
handoff_to_{name} tool; calling it hands the conversation over (see
HandoffTarget). Read once when the ClaudeAgent is constructed,
so every target must already exist — handoff graphs are acyclic.
public IList<HandoffTarget> Handoffs { get; }
Property Value
MaxHandoffs
How many transfers a single run may make, so a long chain of agents each transferring onward terminates. Default 3. Counted across the whole run, and checked against the options of the agent about to transfer.
public int MaxHandoffs { get; set; }
Property Value
MaxParallelTools
How many of a turn's tool calls may execute at once. null (the default) runs them all concurrently, which is fastest but lets one turn open as many connections as the model asked for calls. Set it to the concurrency the slowest tool's dependency can take — a database pool, a rate-limited API. Ordering of results is unaffected.
public int? MaxParallelTools { get; set; }
Property Value
- int?
MaxTokens
The per-response output token limit.
public int MaxTokens { get; set; }
Property Value
MaxTurns
The maximum number of model turns per run — the loop guard against a tool-use cycle that never converges.
public int MaxTurns { get; set; }
Property Value
Mode
How tool effects execute; Shadow intercepts privileged tools.
public ExecutionMode Mode { get; set; }
Property Value
Model
The Claude model id. Defaults to Model.
public string Model { get; set; }
Property Value
OutputSchemaJson
Optional strict JSON Schema the final answer must conform to (structured outputs) —
typically a generated [ClaudeSchema] type's JsonSchema property.
Parse the result with FinalAs<T>(JsonTypeInfo<T>).
public string? OutputSchemaJson { get; set; }
Property Value
PromptCaching
Prompt-cache management; automatic breakpoints by default.
public PromptCacheMode PromptCaching { get; set; }
Property Value
Resilience
Retry, backoff, and timeout behavior for transient API failures.
public ResilienceOptions Resilience { get; }
Property Value
Rules
Declarative tool-call contracts, enforced at runtime (see ToolRules).
public ToolRules Rules { get; }
Property Value
SystemPrompt
The system prompt, or null for none.
public string? SystemPrompt { get; set; }
Property Value
Thinking
Extended thinking configuration.
public ThinkingMode Thinking { get; set; }
Property Value
TokenBudget
Optional hard cap on total tokens (input + output) for a run. When a turn pushes the accumulated usage to or past the budget, the run stops with BudgetExceeded before making another model call.
public long? TokenBudget { get; set; }
Property Value
- long?
ToolFailures
What happens when a tool handler throws or runs too long. By default the failure is reported to the model rather than ending the run (see ToolFailureOptions).
public ToolFailureOptions ToolFailures { get; }
Property Value
Tools
The tools available to the agent, typically generated {Method}Tool properties.
public IList<ToolDefinition> Tools { get; }
Property Value
WebSearch
When set, enables Claude's server-side web search for the run. See WebSearchOptions for the taint-tracking caveat.
public WebSearchOptions? WebSearch { get; set; }
Property Value
Methods
WithOutput<T>()
Constrains the final answer to a [ClaudeSchema] type's compile-time schema.
Pair with RunAsync<T>(string, JsonTypeInfo<T>, CancellationToken) for a typed result end to end.
public AgentOptions WithOutput<T>() where T : IClaudeSchema
Returns
Type Parameters
TA type marked with ClaudeSchemaAttribute.