pub struct AgentLoopBuilder { /* private fields */ }Expand description
Builder for constructing an AgentLoop with validated configuration.
Implementations§
Source§impl AgentLoopBuilder
impl AgentLoopBuilder
Sourcepub fn max_iterations(self, n: usize) -> Self
pub fn max_iterations(self, n: usize) -> Self
Set the maximum number of LLM round-trips before aborting.
Sourcepub fn tools(self, tools: impl IntoIterator<Item = Arc<dyn Tool>>) -> Self
pub fn tools(self, tools: impl IntoIterator<Item = Arc<dyn Tool>>) -> Self
Register multiple tools at once.
Sourcepub fn system_prompt(self, prompt: impl Into<String>) -> Self
pub fn system_prompt(self, prompt: impl Into<String>) -> Self
Set a static system prompt that is injected as a System message
at the beginning of every conversation.
This is a convenience shortcut for registering a ContextProvider
that always returns the given string.
Sourcepub fn context(self, provider: impl ContextProvider + 'static) -> Self
pub fn context(self, provider: impl ContextProvider + 'static) -> Self
Register a context provider that injects dynamic context into the
conversation before each AgentLoop::run call.
Multiple providers can be registered; they are invoked in registration
order and each non-empty result becomes a System message.
Sourcepub fn contexts(
self,
providers: impl IntoIterator<Item = Box<dyn ContextProvider>>,
) -> Self
pub fn contexts( self, providers: impl IntoIterator<Item = Box<dyn ContextProvider>>, ) -> Self
Sourcepub fn tool_timeout(self, duration: Duration) -> Self
pub fn tool_timeout(self, duration: Duration) -> Self
Set a per-tool-call timeout. When a tool takes longer than duration
it returns a ToolResult::error("timed out") instead of blocking.
By default there is no timeout.
Sourcepub fn tool_context(self, ctx: ToolContext) -> Self
pub fn tool_context(self, ctx: ToolContext) -> Self
Set a custom ToolContext that will be passed to every tool invocation.
By default, ToolContext::default() is used. Use this when tools need
access to session-level state such as a working directory or environment
variables.
Sourcepub fn channel_config(self, config: ChannelConfig) -> Self
pub fn channel_config(self, config: ChannelConfig) -> Self
Set the full channel configuration for bounded queues.
See ChannelConfig for details on each field.
Sourcepub fn input_channel_capacity(self, capacity: usize) -> Self
pub fn input_channel_capacity(self, capacity: usize) -> Self
Set the capacity of the user-input channel.
Default: 64.
Sourcepub fn ops_channel_capacity(self, capacity: usize) -> Self
pub fn ops_channel_capacity(self, capacity: usize) -> Self
Set the capacity of the per-turn operations channel.
Default: 64.
Sourcepub fn ops_backpressure(self, policy: BackpressurePolicy) -> Self
pub fn ops_backpressure(self, policy: BackpressurePolicy) -> Self
Set the backpressure policy for the operations channel.
Default: BackpressurePolicy::Block.
Sourcepub fn with_ask_user(self) -> Self
pub fn with_ask_user(self) -> Self
Register the built-in ask_user tool with the default timeout (30s).
Sourcepub fn with_ask_user_timeout(self, timeout: Duration) -> Self
pub fn with_ask_user_timeout(self, timeout: Duration) -> Self
Register the built-in ask_user tool with a custom timeout.