pub struct ClaudeAgentOptions {Show 26 fields
pub prompt: Option<String>,
pub model: Option<String>,
pub system_prompt: Option<String>,
pub append_system_prompt: Option<String>,
pub max_turns: Option<u32>,
pub max_tokens: Option<u32>,
pub session_id: Option<String>,
pub continue_session: bool,
pub cwd: Option<PathBuf>,
pub permission_mode: PermissionMode,
pub allowed_tools: Vec<String>,
pub can_use_tool: Option<CanUseToolCallback>,
pub hooks: Vec<HookDefinition>,
pub mcp_servers: HashMap<String, McpServerConfig>,
pub agents: Vec<AgentDefinition>,
pub sandbox: Option<SandboxSettings>,
pub env: HashMap<String, String>,
pub verbose: bool,
pub cli_path: Option<PathBuf>,
pub extra_cli_args: Vec<String>,
pub connect_timeout: Option<Duration>,
pub control_timeout: Option<Duration>,
pub on_stderr: Option<StderrCallback>,
pub no_cache: bool,
pub temperature: Option<f64>,
pub context_window: Option<f64>,
}Expand description
Configuration options for a Claude Agent SDK query or client.
All fields are public with sensible defaults. Use ..Default::default() for
fields you don’t need to set.
Fields§
§prompt: Option<String>The prompt/message to send. Can be set here or passed to query().
model: Option<String>Model to use (e.g. “claude-sonnet-4-20250514”).
system_prompt: Option<String>System prompt override.
append_system_prompt: Option<String>Append system prompt (added after default).
max_turns: Option<u32>Maximum turns (agentic loops) before stopping.
max_tokens: Option<u32>Maximum tokens in the response.
session_id: Option<String>Resume an existing session by ID.
continue_session: boolContinue the most recent session.
cwd: Option<PathBuf>Working directory for the CLI process.
permission_mode: PermissionModePermission mode for tool usage.
allowed_tools: Vec<String>Specific tools to allow (when using AllowedTools mode).
can_use_tool: Option<CanUseToolCallback>Custom permission callback.
hooks: Vec<HookDefinition>Registered hook definitions.
mcp_servers: HashMap<String, McpServerConfig>MCP servers to register with the CLI.
agents: Vec<AgentDefinition>Sub-agent definitions.
sandbox: Option<SandboxSettings>Sandbox configuration.
env: HashMap<String, String>Additional environment variables for the CLI process.
verbose: boolVerbose output from CLI.
cli_path: Option<PathBuf>Path to the claude CLI binary (auto-detected if None).
extra_cli_args: Vec<String>Custom CLI arguments (appended after built-in ones).
connect_timeout: Option<Duration>Timeout for the initial connection handshake.
control_timeout: Option<Duration>Timeout for control protocol requests.
on_stderr: Option<StderrCallback>Stderr callback - receives stderr lines from CLI process.
no_cache: boolDisallow use of the prompt cache
temperature: Option<f64>Temperature setting
context_window: Option<f64>Context window fraction (0.0-1.0) to use before summarizing.
Implementations§
Source§impl ClaudeAgentOptions
impl ClaudeAgentOptions
Sourcepub fn resolve_cli_path(&self) -> Result<PathBuf>
pub fn resolve_cli_path(&self) -> Result<PathBuf>
Resolve the CLI path: use the configured one or auto-detect.
Trait Implementations§
Source§impl Debug for ClaudeAgentOptions
impl Debug for ClaudeAgentOptions
Source§impl Default for ClaudeAgentOptions
impl Default for ClaudeAgentOptions
Source§fn default() -> ClaudeAgentOptions
fn default() -> ClaudeAgentOptions
Auto Trait Implementations§
impl Freeze for ClaudeAgentOptions
impl !RefUnwindSafe for ClaudeAgentOptions
impl Send for ClaudeAgentOptions
impl Sync for ClaudeAgentOptions
impl Unpin for ClaudeAgentOptions
impl !UnwindSafe for ClaudeAgentOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more