pub struct AgentRuntimeBuilder<S = NeedsConfig> { /* private fields */ }Expand description
Builder for AgentRuntime.
Uses a typestate parameter S to enforce that with_agent_config is called
before build(). Calling build() on a AgentRuntimeBuilder<NeedsConfig>
is a compile-time error.
Typical usage:
let runtime = AgentRuntime::builder() // AgentRuntimeBuilder<NeedsConfig>
.with_memory(store)
.with_agent_config(cfg) // → AgentRuntimeBuilder<HasConfig>
.build(); // → AgentRuntime (infallible)Builder for AgentRuntime.
Implementations§
Source§impl<S> AgentRuntimeBuilder<S>
impl<S> AgentRuntimeBuilder<S>
Sourcepub fn with_memory(self, store: EpisodicStore) -> Self
pub fn with_memory(self, store: EpisodicStore) -> Self
Attach an episodic memory store.
Sourcepub fn with_working_memory(self, wm: WorkingMemory) -> Self
pub fn with_working_memory(self, wm: WorkingMemory) -> Self
Attach a working memory store.
Sourcepub fn with_graph(self, graph: GraphStore) -> Self
pub fn with_graph(self, graph: GraphStore) -> Self
Attach a graph store.
Sourcepub fn with_backpressure(self, guard: BackpressureGuard) -> Self
pub fn with_backpressure(self, guard: BackpressureGuard) -> Self
Attach a backpressure guard.
Sourcepub fn register_tool(self, spec: ToolSpec) -> Self
pub fn register_tool(self, spec: ToolSpec) -> Self
Register a tool available to the agent loop.
Sourcepub fn register_tools(self, specs: impl IntoIterator<Item = ToolSpec>) -> Self
pub fn register_tools(self, specs: impl IntoIterator<Item = ToolSpec>) -> Self
Register multiple tools at once.
Equivalent to calling register_tool for each spec.
Sourcepub fn with_metrics(self, metrics: Arc<RuntimeMetrics>) -> Self
pub fn with_metrics(self, metrics: Arc<RuntimeMetrics>) -> Self
Attach a shared RuntimeMetrics instance.
Sourcepub fn with_token_estimator(self, estimator: Arc<dyn TokenEstimator>) -> Self
pub fn with_token_estimator(self, estimator: Arc<dyn TokenEstimator>) -> Self
Provide a custom TokenEstimator for memory budget calculations.
Replaces the default len / 4 byte-counting heuristic. Use this to
plug in a model-specific tokenizer (e.g. tiktoken, sentencepiece) so
that AgentConfig::max_memory_tokens is respected accurately.
Source§impl AgentRuntimeBuilder<NeedsConfig>
impl AgentRuntimeBuilder<NeedsConfig>
Sourcepub fn with_agent_config(
self,
config: AgentConfig,
) -> AgentRuntimeBuilder<HasConfig>
pub fn with_agent_config( self, config: AgentConfig, ) -> AgentRuntimeBuilder<HasConfig>
Set the agent loop configuration.
After this call the builder transitions to AgentRuntimeBuilder<HasConfig>,
making build() available.
Source§impl AgentRuntimeBuilder<HasConfig>
impl AgentRuntimeBuilder<HasConfig>
Sourcepub fn build(self) -> AgentRuntime
pub fn build(self) -> AgentRuntime
Build the AgentRuntime.
This is infallible: the typestate guarantees agent_config is present.