Skip to main content

AgentSessionConfig

Struct AgentSessionConfig 

Source
pub struct AgentSessionConfig {
Show 44 fields pub max_tool_iterations: usize, pub max_tool_retries: usize, pub max_retry_duration_secs: u64, pub retry_base_ms: u64, pub retry_max_ms: u64, pub parameter_reformat_provider: String, pub tool_repeat_threshold: usize, pub tool_summarization: bool, pub tool_call_cutoff: usize, pub max_tool_calls_per_session: Option<u32>, pub overflow_config: OverflowConfig, pub permission_policy: PermissionPolicy, pub model_name: String, pub embed_model: String, pub semantic_cache_enabled: bool, pub semantic_cache_threshold: f32, pub semantic_cache_max_candidates: u32, pub budget_tokens: usize, pub soft_compaction_threshold: f32, pub hard_compaction_threshold: f32, pub compaction_preserve_tail: usize, pub compaction_cooldown_turns: u8, pub prune_protect_tokens: usize, pub redact_credentials: bool, pub security: SecurityConfig, pub timeouts: TimeoutConfig, pub learning: LearningConfig, pub document_config: DocumentConfig, pub graph_config: GraphConfig, pub persona_config: PersonaConfig, pub trajectory_config: TrajectoryConfig, pub category_config: CategoryConfig, pub tree_config: TreeConfig, pub microcompact_config: MicrocompactConfig, pub autodream_config: AutoDreamConfig, pub magic_docs_config: MagicDocsConfig, pub anomaly_config: AnomalyConfig, pub result_cache_config: ResultCacheConfig, pub utility_config: UtilityScoringConfig, pub orchestration_config: OrchestrationConfig, pub debug_config: DebugConfig, pub server_compaction: bool, pub budget_hint_enabled: bool, pub secrets: Arc<[(String, Secret)]>,
}
Expand description

All config-derived fields needed to configure an Agent session.

This is the single source of truth for config → agent wiring. Adding a new config field requires exactly three changes:

  1. Add the field here.
  2. Map it in AgentSessionConfig::from_config.
  3. Apply it in super::Agent::apply_session_config (destructure triggers a compile error if you forget step 3 — see the S4 note in the critic handoff).

§What is NOT here

  • Shared runtime objects (provider, registry, memory, mcp_manager, etc.) — these are expensive to create and shared across sessions; they stay in SharedAgentDeps.
  • ACP-specific fields (acp_max_sessions, bearer token, etc.) — transport-level, not agent-level.
  • Optional runtime providers (summary_provider, judge_provider, quarantine_provider) — these contain HTTP client pools (AnyProvider) that carry runtime state; callers wire them separately via with_summary_provider / with_judge_provider / apply_quarantine_provider.
  • mcp_config — passed alongside runtime MCP objects in with_mcp(); separating it from mcp_tools / mcp_manager would make the call site awkward.
  • Runner-only fields (compression, routing, autosave, hybrid_search, trust_config, disambiguation_threshold, logging_config, subagent, experiment, instruction, lsp_hooks, response_cache, cost_tracker) — not used in ACP sessions; keeping them out avoids unused-field noise and prevents inadvertent ACP behavior changes.
  • Scheduler runtime objects (scheduler_executor, broadcast senders) — runtime state, not config-derived values.

Fields§

§max_tool_iterations: usize§max_tool_retries: usize§max_retry_duration_secs: u64§retry_base_ms: u64§retry_max_ms: u64§parameter_reformat_provider: String§tool_repeat_threshold: usize§tool_summarization: bool§tool_call_cutoff: usize§max_tool_calls_per_session: Option<u32>§overflow_config: OverflowConfig§permission_policy: PermissionPolicy§model_name: String§embed_model: String§semantic_cache_enabled: bool§semantic_cache_threshold: f32§semantic_cache_max_candidates: u32§budget_tokens: usize§soft_compaction_threshold: f32§hard_compaction_threshold: f32§compaction_preserve_tail: usize§compaction_cooldown_turns: u8§prune_protect_tokens: usize§redact_credentials: bool§security: SecurityConfig§timeouts: TimeoutConfig§learning: LearningConfig§document_config: DocumentConfig§graph_config: GraphConfig§persona_config: PersonaConfig§trajectory_config: TrajectoryConfig§category_config: CategoryConfig§tree_config: TreeConfig§microcompact_config: MicrocompactConfig§autodream_config: AutoDreamConfig§magic_docs_config: MagicDocsConfig§anomaly_config: AnomalyConfig§result_cache_config: ResultCacheConfig§utility_config: UtilityScoringConfig§orchestration_config: OrchestrationConfig§debug_config: DebugConfig§server_compaction: bool§budget_hint_enabled: bool

Inject <budget> XML into the volatile system prompt section (#2267).

§secrets: Arc<[(String, Secret)]>

Custom secrets from config.

Stored as Arc because Secret intentionally does not implement Clone — the wrapper prevents accidental duplication. Iteration produces new Secret values via Secret::new(v.expose()) on the consumption side.

Implementations§

Source§

impl AgentSessionConfig

Source

pub fn from_config(config: &Config, budget_tokens: usize) -> Self

Build from a resolved Config snapshot and a pre-computed budget_tokens.

budget_tokens is passed as a parameter because its computation (auto_budget_tokens) depends on the active provider and must happen before AgentSessionConfig is constructed.

Trait Implementations§

Source§

impl Clone for AgentSessionConfig

Source§

fn clone(&self) -> AgentSessionConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. 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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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 = 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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