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: StringThe 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: boolBackground 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: boolEnables 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: usize0 = unlimited. The default is unlimited.
max_hook_continues: u32Hard upper limit on forced continuations from the before turn-end hook —
prevents infinite loops from repeated hook Continue calls. Default: 3.
subagent_max_depth: u32Maximum 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
impl Clone for TurnConfig
Source§fn clone(&self) -> TurnConfig
fn clone(&self) -> TurnConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more