Skip to main content

ClaudeAgentOptions

Struct ClaudeAgentOptions 

Source
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: bool

Continue the most recent session.

§cwd: Option<PathBuf>

Working directory for the CLI process.

§permission_mode: PermissionMode

Permission 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: bool

Verbose 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: bool

Disallow 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

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ClaudeAgentOptions

Source§

fn default() -> ClaudeAgentOptions

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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