Skip to main content

TurnOptions

Struct TurnOptions 

Source
pub struct TurnOptions {
Show 21 fields pub max_steps: Option<usize>, pub max_tool_concurrency: usize, pub capability_mode: CapabilityMode, pub cancel: CancellationToken, pub deadline: Option<Deadline>, pub session_id: Option<SessionId>, pub agent_id: Option<AgentId>, pub cwd: Option<PathBuf>, pub compaction: Option<Arc<dyn CompactionStrategy>>, pub approval: Arc<dyn ApprovalGate>, pub approval_policy: ApprovalPolicy, pub stop_gates: Option<Arc<GateChain>>, pub metrics: SharedMetrics, pub spawn_depth: Option<u32>, pub max_output_tokens: Option<u32>, pub use_stream: bool, pub contributors: Arc<dyn TurnLifecycleContributor>, pub interject_rx: Option<Arc<Mutex<UnboundedReceiver<Message>>>>, pub context_window_tokens: Option<u32>, pub context_overflow_ratio: f32, pub fail_on_context_overflow: bool,
}
Expand description

Options for a single turn.

Fields§

§max_steps: Option<usize>

Hard step ceiling (defaults to agent max_steps).

§max_tool_concurrency: usize

Tool concurrency.

§capability_mode: CapabilityMode

Capability mode for tools.

§cancel: CancellationToken

Cancel token.

§deadline: Option<Deadline>

Deadline.

§session_id: Option<SessionId>

Session id for context.

§agent_id: Option<AgentId>

Agent id for context.

§cwd: Option<PathBuf>

Working directory for path tools.

§compaction: Option<Arc<dyn CompactionStrategy>>

Compaction strategy applied before each sample when present.

§approval: Arc<dyn ApprovalGate>

Approval gate for tools.

§approval_policy: ApprovalPolicy

When to consult approval.

§stop_gates: Option<Arc<GateChain>>

Optional override stop-gate chain (default: from agent definition).

§metrics: SharedMetrics

Metrics sink (default no-op).

§spawn_depth: Option<u32>

Nesting depth when this turn is a host-spawned agent (None = top-level session).

§max_output_tokens: Option<u32>

Optional max output tokens for the sampler.

§use_stream: bool

Prefer LlmSampler::sample_stream and aggregate into a full response.

§contributors: Arc<dyn TurnLifecycleContributor>

Lifecycle contributors (W3.5).

§interject_rx: Option<Arc<Mutex<UnboundedReceiver<Message>>>>

Optional mid-turn user interjections drained before each sample (W3.6).

§context_window_tokens: Option<u32>

Context window size for preflight overflow (tokens). None disables check.

§context_overflow_ratio: f32

Soft threshold ratio of context window (default 0.9).

§fail_on_context_overflow: bool

When true, overflow after compaction is a hard error; else continue.

Implementations§

Source§

impl TurnOptions

Source

pub fn with_max_messages(self, max: usize) -> Result<Self, MachiError>

Cap conversation length via MaxMessages strategy.

§Errors

Returns error when max == 0.

Source

pub fn with_compaction(self, strategy: Arc<dyn CompactionStrategy>) -> Self

Install a compaction strategy.

Source

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

Set cwd for tools.

Source

pub const fn with_capability(self, mode: CapabilityMode) -> Self

Set capability mode.

Source

pub const fn with_max_steps(self, max_steps: usize) -> Self

Set max steps.

Source

pub fn with_cancel(self, cancel: CancellationToken) -> Self

Set cancel token.

Source

pub fn with_approval(self, gate: Arc<dyn ApprovalGate>) -> Self

Set approval gate.

Source

pub const fn with_approval_policy(self, policy: ApprovalPolicy) -> Self

Set approval policy.

Source

pub fn with_metrics(self, metrics: SharedMetrics) -> Self

Set metrics sink.

Source

pub const fn with_deadline(self, deadline: Deadline) -> Self

Set absolute deadline for the turn (sample + tools).

Source

pub const fn with_stream(self, use_stream: bool) -> Self

Prefer streaming sample aggregation for this turn.

Source

pub fn with_stop_gates(self, gates: Arc<GateChain>) -> Self

Override stop-gate chain.

Source

pub fn with_contributors( self, contributors: Arc<dyn TurnLifecycleContributor>, ) -> Self

Install lifecycle contributors (W3.5).

Source

pub fn with_interject_rx( self, rx: Arc<Mutex<UnboundedReceiver<Message>>>, ) -> Self

Mid-turn interjection channel drained before each sample (W3.6).

Source

pub const fn with_context_window(self, tokens: u32) -> Self

Enable preflight context overflow checks (W3.2).

Trait Implementations§

Source§

impl Clone for TurnOptions

Source§

fn clone(&self) -> TurnOptions

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 TurnOptions

Source§

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

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

impl Default for TurnOptions

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> 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 = 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