Skip to main content

AgentConfig

Struct AgentConfig 

Source
pub struct AgentConfig {
Show 29 fields pub path: TaskPath, pub base_system_prompt: Option<String>, pub prompt_assembly: Option<Arc<PromptAssembly>>, pub prompt_profile: PromptProfile, pub max_iterations: Option<usize>, pub cwd: PathBuf, pub env: HashMap<String, String>, pub max_tool_result_chars: usize, pub max_message_tool_results_chars: usize, pub policies: Arc<PolicyRegistry>, pub storage: Option<Arc<dyn Storage>>, pub tool_diagnostics: Option<Arc<dyn ToolDiagnosticsSink>>, pub compaction: Option<Arc<dyn HistoryCompactionStrategy>>, pub permission_engine: Option<PermissionEngine>, pub approval_handler: Option<Arc<dyn ApprovalHandler>>, pub tool_concurrency_limit: usize, pub token_budget: Option<TokenBudget>, pub retry: RetryConfig, pub auto_validate_schema: bool, pub cancellation: CancellationState, pub tool_timeout_ms: Option<u64>, pub max_file_read_bytes: usize, pub skill_registry: Option<Arc<SkillRegistry>>, pub plugin_registry: Option<Arc<PluginRegistry>>, pub task_manager: Option<Arc<TaskManager>>, pub memory_injector: Option<Arc<MemoryInjector>>, pub skill_injector: Option<Arc<SkillInjector>>, pub mcp_manager: Option<Arc<McpManager>>, pub event_channel: Option<EventChannelConfig>,
}
Expand description

Configuration for an AgentSession.

Build with Default::default and override fields as needed. All fields are public so callers don’t need a builder for simple cases.

Fields§

§path: TaskPath

Workflow path classification for the current task. Influences iteration budget, timeout, concurrency, and the system-prompt guidance injected at turn time.

§base_system_prompt: Option<String>

Optional base instruction appended to the identity section of the system prompt. For full control, use prompt_assembly instead.

§prompt_assembly: Option<Arc<PromptAssembly>>

Optional pre-built prompt assembly. When set, the runtime uses this instead of constructing the prompt from base_system_prompt alone.

§prompt_profile: PromptProfile

Controls how much built-in prompt guidance is injected when the runtime constructs the default prompt assembly.

§max_iterations: Option<usize>

Optional maximum number of model ⇄ tool round-trips per turn before the loop aborts with AgentError::MaxIterations.

None means the model/tool loop is allowed to continue until the model finishes, the turn is cancelled, or another runtime limit is reached.

§cwd: PathBuf

Working directory used as the root for filesystem tools and shell commands.

§env: HashMap<String, String>

Environment variables exposed to shell-based tools.

§max_tool_result_chars: usize

Hard cap on the character length of any individual tool result. Anything longer is replaced with a truncated preview to protect the context window.

§max_message_tool_results_chars: usize

Hard cap on the aggregate character length of all tool results within a single message. When N parallel tool calls collectively exceed this, the largest results are truncated to fit. Prevents a turn with many tool calls from flooding the context window even when each result individually stays under max_tool_result_chars.

§policies: Arc<PolicyRegistry>

Registry of semantic runtime policies.

§storage: Option<Arc<dyn Storage>>

Optional persistent backing store for session messages.

§tool_diagnostics: Option<Arc<dyn ToolDiagnosticsSink>>

Optional sink for sanitized tool failure diagnostics.

§compaction: Option<Arc<dyn HistoryCompactionStrategy>>

Optional history-level compaction strategy (summarisation, etc.).

§permission_engine: Option<PermissionEngine>

Optional rule-based permission engine consulted before every tool call.

§approval_handler: Option<Arc<dyn ApprovalHandler>>

Optional handler invoked when a tool call requires explicit human approval.

§tool_concurrency_limit: usize

Maximum number of concurrency-safe tools to run in parallel within a single batch.

§token_budget: Option<TokenBudget>

Optional token budget that triggers proactive compaction.

§retry: RetryConfig

Retry configuration for transient provider failures. When None, provider calls are not retried.

§auto_validate_schema: bool

Whether to automatically validate tool arguments against the tool’s input_schema after the tool’s own validate method runs.

§cancellation: CancellationState

Shared cancellation state. Hosts call cancel() to interrupt a running turn and reset() before starting the next turn.

§tool_timeout_ms: Option<u64>

Per-tool execution timeout in milliseconds. When set, any tool that runs longer than this will be interrupted and its result will be an is_error: true timeout so the model can recover.

§max_file_read_bytes: usize

Maximum number of bytes the built-in file tools will read from a single file. Files larger than this are rejected to avoid OOMing the agent.

§skill_registry: Option<Arc<SkillRegistry>>

Optional skill registry. When set, the Skill tool and the default prompt assembly can use registered skills (including bundled Superpowers skills).

§plugin_registry: Option<Arc<PluginRegistry>>

Optional plugin registry. When set, enabled plugins’ components are applied to tool/policy/skill registries at session startup.

§task_manager: Option<Arc<TaskManager>>

Optional task manager used by long-running tools such as background subagents to publish lifecycle state and output.

§memory_injector: Option<Arc<MemoryInjector>>

Optional memory injector for dynamic per-turn memory scoring. When set, memories are scored against the user’s current input and injected as system reminders before the first provider call of each turn.

§skill_injector: Option<Arc<SkillInjector>>

Optional skill injector for dynamic per-turn skill discovery. When set, top matching skills are injected as system reminders before the first provider call of each turn.

§mcp_manager: Option<Arc<McpManager>>

Optional MCP manager. When set, MCP server tools are bridged into the tool registry and an MCP tools section is added to the prompt assembly.

§event_channel: Option<EventChannelConfig>

Optional configuration for the bidirectional HTTP event channel. When set and enabled is true, the session starts an embedded HTTP server on the configured address, accepting external event injection (POST /inject) and streaming TurnEvents via SSE (GET /events).

Implementations§

Source§

impl AgentConfig

Source

pub fn request_cancel(&self)

Request cancellation and wake any runtime await that is listening for it.

Source

pub fn reset_cancel(&self)

Clear a previous cancellation request before starting a new turn.

Source

pub fn validate(&self) -> Result<(), AgentError>

Validate configuration values and return a structured error for any dangerous or nonsensical combination.

Source

pub fn with_default_prompt_assembly( self, tools: Arc<ToolRegistry>, ) -> Result<Self, AgentError>

Replace base_system_prompt with the default modular prompt assembly.

This is the recommended way to use telos-agent’s built-in default prompt sections without manually wiring each section.

Source

pub fn with_path(self, path: TaskPath) -> Self

Apply path-appropriate defaults for timeouts, token budgets, and concurrency. Call after setting custom values if you want the path to override them.

KnobFastStandardHeavy
max_iterationsNoneNoneNone
tool_concurrency_limit10105
token_budgetNoneNone308k
tool_timeout_ms30_000None60_000
Source

pub fn with_bundled_skills(self) -> Self

Load bundled skills into a fresh skill registry attached to this config.

Source

pub fn apply_plugins( &self, tools: ToolRegistry, policies: PolicyRegistry, skills: SkillRegistry, mcp: McpManager, prompt: PromptAssembly, ) -> (ToolRegistry, PolicyRegistry, SkillRegistry, McpManager, PromptAssembly, Result<(), Vec<PluginError>>)

Apply plugin components into the agent registries.

Call this before creating an AgentSession to populate tools/policies/skills/mcp/prompt with enabled plugin content. Always returns the registries (even on error) so callers can continue with degraded state.

Trait Implementations§

Source§

impl Clone for AgentConfig

Source§

fn clone(&self) -> AgentConfig

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
Source§

impl Debug for AgentConfig

Source§

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

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

impl Default for AgentConfig

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.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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.

§

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

§

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
§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,