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: usizeTool concurrency.
capability_mode: CapabilityModeCapability mode for tools.
cancel: CancellationTokenCancel 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: ApprovalPolicyWhen to consult approval.
stop_gates: Option<Arc<GateChain>>Optional override stop-gate chain (default: from agent definition).
metrics: SharedMetricsMetrics 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: boolPrefer 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: f32Soft threshold ratio of context window (default 0.9).
fail_on_context_overflow: boolWhen true, overflow after compaction is a hard error; else continue.
Implementations§
Source§impl TurnOptions
impl TurnOptions
Sourcepub fn with_max_messages(self, max: usize) -> Result<Self, MachiError>
pub fn with_max_messages(self, max: usize) -> Result<Self, MachiError>
Sourcepub fn with_compaction(self, strategy: Arc<dyn CompactionStrategy>) -> Self
pub fn with_compaction(self, strategy: Arc<dyn CompactionStrategy>) -> Self
Install a compaction strategy.
Sourcepub const fn with_capability(self, mode: CapabilityMode) -> Self
pub const fn with_capability(self, mode: CapabilityMode) -> Self
Set capability mode.
Sourcepub const fn with_max_steps(self, max_steps: usize) -> Self
pub const fn with_max_steps(self, max_steps: usize) -> Self
Set max steps.
Sourcepub fn with_cancel(self, cancel: CancellationToken) -> Self
pub fn with_cancel(self, cancel: CancellationToken) -> Self
Set cancel token.
Sourcepub fn with_approval(self, gate: Arc<dyn ApprovalGate>) -> Self
pub fn with_approval(self, gate: Arc<dyn ApprovalGate>) -> Self
Set approval gate.
Sourcepub const fn with_approval_policy(self, policy: ApprovalPolicy) -> Self
pub const fn with_approval_policy(self, policy: ApprovalPolicy) -> Self
Set approval policy.
Sourcepub fn with_metrics(self, metrics: SharedMetrics) -> Self
pub fn with_metrics(self, metrics: SharedMetrics) -> Self
Set metrics sink.
Sourcepub const fn with_deadline(self, deadline: Deadline) -> Self
pub const fn with_deadline(self, deadline: Deadline) -> Self
Set absolute deadline for the turn (sample + tools).
Sourcepub const fn with_stream(self, use_stream: bool) -> Self
pub const fn with_stream(self, use_stream: bool) -> Self
Prefer streaming sample aggregation for this turn.
Sourcepub fn with_stop_gates(self, gates: Arc<GateChain>) -> Self
pub fn with_stop_gates(self, gates: Arc<GateChain>) -> Self
Override stop-gate chain.
Sourcepub fn with_contributors(
self,
contributors: Arc<dyn TurnLifecycleContributor>,
) -> Self
pub fn with_contributors( self, contributors: Arc<dyn TurnLifecycleContributor>, ) -> Self
Install lifecycle contributors (W3.5).
Sourcepub fn with_interject_rx(
self,
rx: Arc<Mutex<UnboundedReceiver<Message>>>,
) -> Self
pub fn with_interject_rx( self, rx: Arc<Mutex<UnboundedReceiver<Message>>>, ) -> Self
Mid-turn interjection channel drained before each sample (W3.6).
Sourcepub const fn with_context_window(self, tokens: u32) -> Self
pub const fn with_context_window(self, tokens: u32) -> Self
Enable preflight context overflow checks (W3.2).
Trait Implementations§
Source§impl Clone for TurnOptions
impl Clone for TurnOptions
Source§fn clone(&self) -> TurnOptions
fn clone(&self) -> TurnOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more