Skip to main content

TurnConfig

Struct TurnConfig 

Source
pub struct TurnConfig {
Show 18 fields pub provider: String, pub model: String, pub allowed_models: Option<Vec<String>>, pub base_prompt: BasePromptConfig, pub system_prompt: Option<String>, pub prompt: PromptConfig, pub sampling: SamplingParams, pub request_limit: TurnRequestLimit, pub compact_threshold_tokens: Option<u64>, pub compact_ratio: Option<f64>, pub background_compact_enabled: bool, pub compact_soft_ratio: Option<f64>, pub microcompact_enabled: bool, pub microcompact_ratio: Option<f64>, pub max_llm_retries: u32, pub max_concurrent_tools: usize, pub max_hook_continues: u32, pub subagent_max_depth: u32,
}
Expand description

Configuration for a turn.

Fields§

§provider: String

The selected provider vendor (the provider half of the selection key). Together with Self::model, this is used to resolve the actual provider entry in the registry by the (vendor, model) pair.

§model: String§allowed_models: Option<Vec<String>>§base_prompt: BasePromptConfig§system_prompt: Option<String>§prompt: PromptConfig§sampling: SamplingParams§request_limit: TurnRequestLimit§compact_threshold_tokens: Option<u64>

Explicit absolute override for the compaction threshold (in tokens). When Some, takes precedence over the value inferred from Self::compact_ratio. When None, the threshold is automatically derived from the ratio.

§compact_ratio: Option<f64>

Compression threshold as a fraction of the model’s context_window (e.g. 0.85 = trigger when usage exceeds 85%). This is the hard watermark: when reached, if no background compaction is in flight, the turn main loop performs synchronous compaction as a fallback (blocking the current turn but guaranteeing the context is not exceeded). None = no automatic ratio-based compression (and if no absolute threshold is set either, no compression occurs for this turn). Only effective when compact_threshold_tokens is None and the model exposes a context_window. See session/turn/compact.rs for details.

§background_compact_enabled: bool

Background full compaction toggle. When true, once the soft watermark derived from Self::compact_soft_ratio is exceeded, a summarization compaction is started asynchronously (without blocking the current turn); it quietly compresses history before the hard watermark is hit. When disabled, only synchronous compaction at the hard watermark remains. See session/turn/compaction_slot.rs.

§compact_soft_ratio: Option<f64>

Soft watermark for background compaction, as a fraction of context_window (default 0.7). Must be less than compact_ratio (the hard watermark) to leave a window between soft and hard for background summarization to complete. Only effective when background_compact_enabled is set and a threshold can be derived.

§microcompact_enabled: bool

Enables micro‑compaction. When true, each turn first runs a micro‑compaction (cleans oversized tool_result in older turns, without calling the LLM or deleting messages) at the water level above Self::microcompact_ratio, deferring expensive full compaction. See session/turn/microcompact.rs.

§microcompact_ratio: Option<f64>

Micro‑compaction watermark as a fraction of context_window (default 0.6). Typically below the soft watermark — micro‑compaction is the cheapest first line of defense. Only effective when microcompact_enabled and a threshold can be derived.

§max_llm_retries: u32§max_concurrent_tools: usize

0 = unlimited. The default is unlimited.

§max_hook_continues: u32

Hard upper limit on forced continuations from the before turn-end hook — prevents infinite loops from repeated hook Continue calls. Default: 3.

§subagent_max_depth: u32

Maximum subagent nesting depth (vertical recursion limit) for this turn. spawn_agent uses this to pass the “remaining depth” to tools via crate::tool::ToolContext::subagent_depth; a child agent’s nested turn receives subagent_max_depth = parent’s remaining depth minus one. 0 means this turn’s tool set contains no spawn_agent, structurally forbidding dispatch — replacing the old hardcoded gate of “whitelist never contains spawn_agent”. Default: DEFAULT_SUBAGENT_MAX_DEPTH.

Trait Implementations§

Source§

impl Clone for TurnConfig

Source§

fn clone(&self) -> TurnConfig

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 TurnConfig

Source§

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

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

impl Default for TurnConfig

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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

Source§

impl<T> IntoOption<T> for T

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