Skip to main content

ClaudeAgentOptions

Struct ClaudeAgentOptions 

Source
pub struct ClaudeAgentOptions {
Show 37 fields pub tools: Option<ToolsOption>, pub allowed_tools: Vec<String>, pub system_prompt: Option<SystemPrompt>, pub mcp_servers: McpServersOption, pub permission_mode: Option<PermissionMode>, pub continue_conversation: bool, pub resume: Option<String>, pub max_turns: Option<i64>, pub max_budget_usd: Option<f64>, pub disallowed_tools: Vec<String>, pub model: Option<String>, pub fallback_model: Option<String>, pub betas: Vec<String>, pub permission_prompt_tool_name: Option<String>, pub cwd: Option<PathBuf>, pub cli_path: Option<PathBuf>, pub settings: Option<String>, pub add_dirs: Vec<PathBuf>, pub env: HashMap<String, String>, pub extra_args: HashMap<String, Option<String>>, pub max_buffer_size: Option<usize>, pub can_use_tool: Option<CanUseToolCallback>, pub hooks: Option<HashMap<String, Vec<HookMatcher>>>, pub user: Option<String>, pub include_partial_messages: bool, pub fork_session: bool, pub agents: Option<HashMap<String, AgentDefinition>>, pub setting_sources: Option<Vec<SettingSource>>, pub sandbox: Option<SandboxSettings>, pub strict_settings_merge: bool, pub plugins: Vec<SdkPluginConfig>, pub max_thinking_tokens: Option<i64>, pub thinking: Option<ThinkingConfig>, pub effort: Option<String>, pub output_format: Option<Value>, pub enable_file_checkpointing: bool, pub stderr: Option<StderrCallback>,
}
Expand description

Main configuration for Claude Code queries and sessions.

This is the primary configuration struct passed to query() or ClaudeSdkClient::new(). All fields are optional and have sensible defaults.

Corresponds to the Python SDK’s ClaudeAgentOptions dataclass.

§Fields

FieldDescription
toolsTools configuration — explicit list or preset
allowed_toolsList of allowed tool names
system_promptSystem prompt — custom text or preset
mcp_serversMCP server configurations
permission_modePermission mode for tool usage
continue_conversationContinue the most recent conversation
resumeSession ID to resume
max_turnsMaximum conversation turns
max_budget_usdMaximum budget in USD for the session
disallowed_toolsList of disallowed tool names
modelClaude model to use
fallback_modelFallback model if the primary fails
betasBeta features to enable
permission_prompt_tool_nameMCP tool name for permission prompts
cwdCurrent working directory
cli_pathCustom path to the Claude Code CLI executable
settingsPath to settings file or inline JSON
add_dirsAdditional directories Claude can access
envEnvironment variables
extra_argsAdditional CLI arguments
max_buffer_sizeMaximum bytes when buffering CLI stdout
can_use_toolTool permission callback function
hooksHook configurations for intercepting events
userUser identifier
include_partial_messagesInclude StreamEvent partial messages
fork_sessionFork to new session ID when resuming
agentsProgrammatically defined subagents
setting_sourcesWhich filesystem settings to load
sandboxSandbox configuration
strict_settings_mergeFail instead of warn when sandbox/settings JSON merge fails
pluginsLocal plugins to load
max_thinking_tokensDeprecated: use thinking instead
thinkingExtended thinking configuration
effortEffort level ("low", "medium", "high", "max")
output_formatStructured output format (e.g., JSON schema)
enable_file_checkpointingEnable file change tracking for rewinding

Fields§

§tools: Option<ToolsOption>

Tools configuration. Use ToolsOption::Preset with ToolsPreset::default() for Claude Code’s default tools.

§allowed_tools: Vec<String>

List of allowed tool names.

§system_prompt: Option<SystemPrompt>

System prompt configuration. Pass a string via SystemPrompt::Text for a custom prompt, or use SystemPrompt::Preset for Claude Code’s built-in system prompt.

§mcp_servers: McpServersOption

MCP server configurations or path to config file.

§permission_mode: Option<PermissionMode>

Permission mode for tool usage.

§continue_conversation: bool

Continue the most recent conversation.

§resume: Option<String>

Session ID to resume.

§max_turns: Option<i64>

Maximum conversation turns.

§max_budget_usd: Option<f64>

Maximum budget in USD for the session.

§disallowed_tools: Vec<String>

List of disallowed tool names.

§model: Option<String>

Claude model to use (e.g., "sonnet", "opus").

§fallback_model: Option<String>

Fallback model to use if the primary model fails.

§betas: Vec<String>

Beta features to enable.

§permission_prompt_tool_name: Option<String>

MCP tool name for permission prompts. Mutually exclusive with can_use_tool.

§cwd: Option<PathBuf>

Current working directory for the Claude Code process.

§cli_path: Option<PathBuf>

Custom path to the Claude Code CLI executable.

§settings: Option<String>

Path to settings file or inline JSON string.

§add_dirs: Vec<PathBuf>

Additional directories Claude can access.

§env: HashMap<String, String>

Environment variables to pass to the CLI process.

§extra_args: HashMap<String, Option<String>>

Additional CLI arguments to pass directly to the CLI. Keys are flag names (without --), values are optional flag values.

§max_buffer_size: Option<usize>

Maximum bytes when buffering CLI stdout. Defaults to 1MB.

§can_use_tool: Option<CanUseToolCallback>

Custom tool permission callback function.

§hooks: Option<HashMap<String, Vec<HookMatcher>>>

Hook configurations for intercepting events. Keys are hook event names (e.g., "PreToolUse", "PostToolUse", "UserPromptSubmit").

§user: Option<String>

User identifier.

§include_partial_messages: bool

Include partial message streaming events (StreamEvent).

§fork_session: bool

When resuming with resume, fork to a new session ID instead of continuing the original session.

§agents: Option<HashMap<String, AgentDefinition>>

Programmatically defined subagents.

§setting_sources: Option<Vec<SettingSource>>

Control which filesystem settings to load. When omitted, no settings are loaded (SDK isolation).

§sandbox: Option<SandboxSettings>

Sandbox configuration for command execution isolation.

§strict_settings_merge: bool

When true, fail command construction if sandbox merge with settings fails. When false, merge failures emit a warning and fallback to sandbox-only settings.

§plugins: Vec<SdkPluginConfig>

Local plugins to load.

§max_thinking_tokens: Option<i64>

Deprecated: Maximum tokens for thinking blocks. Use thinking instead.

§thinking: Option<ThinkingConfig>

Extended thinking configuration. Takes precedence over max_thinking_tokens.

§effort: Option<String>

Effort level for thinking depth ("low", "medium", "high", "max").

§output_format: Option<Value>

Output format for structured responses. Example: {"type": "json_schema", "schema": {...}}

§enable_file_checkpointing: bool

Enable file change tracking for rewinding via ClaudeSdkClient::rewind_files().

§stderr: Option<StderrCallback>

Optional callback for stderr output lines from the CLI process.

When set, stderr is piped and each non-empty line is passed to this callback. When None, stderr is still drained to prevent subprocess blocking, but lines are discarded.

Trait Implementations§

Source§

impl Clone for ClaudeAgentOptions

Source§

fn clone(&self) -> ClaudeAgentOptions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for ClaudeAgentOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more