Skip to main content

Options

Struct Options 

Source
pub struct Options { /* private fields */ }
Expand description

The options a session starts (or resumes) with. Every field left unset takes R2.2’s default, which switches off everything personal.

Implementations§

Source§

impl Options

Source

pub fn new() -> Self

Every field at its default.

Source

pub fn plain(system_prompt: impl Into<String>) -> Self

An agent that is not a coding agent (R4): no built-in tools, and system_prompt in place of harness’s own.

Source

pub fn model(self, model: impl Into<String>) -> Self

The model, as --model takes it.

Source

pub fn thinking(self, thinking: impl Into<String>) -> Self

The thinking level, as --thinking takes it.

Source

pub fn mode(self, mode: Mode) -> Self

The starting mode; it governs the built-in tools.

Source

pub fn sandbox(self, sandbox: Sandbox) -> Self

The sandbox for built-in commands.

Source

pub fn builtin_tools<I, S>(self, names: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

The most built-in tools the session ever offers (R2.2.3); empty offers none.

Source

pub fn system_prompt(self, prompt: SystemPrompt) -> Self

The system prompt policy (R2.3).

Source

pub fn project_instructions(self, on: bool) -> Self

Read the project’s AGENTS.md / CLAUDE.md.

Source

pub fn user_config(self, on: bool) -> Self

Read the user’s own setup (config, account, saved model).

Source

pub fn skills(self, on: bool) -> Self

Discover skills.

Source

pub fn agents(self, on: bool) -> Self

Discover agent definitions.

Source

pub fn hooks(self, on: bool) -> Self

Run hooks from config; needs user_config(true).

Source

pub fn mcp_server(self, name: impl Into<String>, server: Value) -> Self

One MCP server for the session, in the [mcp.servers] table’s shape as JSON.

Source

pub fn approval_timeout(self, timeout: Option<Duration>) -> Self

How long an approval request waits for an answer; None waits for ever. Sent in whole seconds, rounded up, at least one.

Source

pub fn allow_escapes(self, on: bool) -> Self

As --allow-escapes.

Source

pub fn max_iterations(self, n: u32) -> Self

As --max-iterations.

Source

pub fn cwd(self, dir: impl Into<PathBuf>) -> Self

The session’s working folder.

Source

pub fn env(self, key: impl Into<OsString>, value: impl Into<OsString>) -> Self

A variable added to the session’s environment.

Source

pub fn binary(self, path: impl Into<PathBuf>) -> Self

Use this harness binary (R12.1).

Source

pub fn mock(self, path: impl Into<PathBuf>) -> Self

Answer the model from this mock file, with no key and no network (R5).

Source

pub fn tool(self, tool: Tool) -> Self

A tool the program runs (R8.4), offered to the model after the built-in tools, in the order added.

Source

pub fn on_approval<F, Fut>(self, callback: F) -> Self
where F: Fn(ApprovalRequest) -> Fut + Send + Sync + 'static, Fut: Future<Output = Decision> + Send + 'static,

Answers every approval request with callback’s decision (R8.3.2); the requests are then not yielded as events. A callback that panics, or returns a decision not among the request’s choices, answers Deny with the failure as the reason.

Trait Implementations§

Source§

impl Clone for Options

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Options

The environment’s values are left out: they may hold keys.

Source§

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

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

impl Default for Options

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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