pub struct AgentSystemBuilder<C, S, M, H = NoRapHttp>{ /* private fields */ }Expand description
Builder for an AgentSystem.
Two construction modes decide how messages flow back into the system:
AgentSystemBuilder::newtakes the platform’s ownInputSender(e.g. an SQS sender on Lambda). The built system exposes the step API: the platform delivers each thread’s message batches and callsAgentSystem::stepper batch.AgentSystemBuilder::new_localcreates an internal in-process queue (ChannelSender).startthen runs the full actor-system-style driver: a router that spawns one worker per thread, batches inputs, handles interruption, deferral, idling, and auto-compaction.
Tool/prompt configuration is either static (the tools,
extra_system_prompt, and rap_notifier methods — every thread sees the
same set) or dynamic via thread_config, which
resolves a ThreadConfig per thread load. The
built-in thread and subscription tools (spawn_thread,
report_to_parent, close_thread, send_message_to_child,
cancel_subscription, sleep_until_event_or_input) are added on top in
both cases; disable with
without_builtin_tools.
Implementations§
Source§impl<C, S, M, H> AgentSystemBuilder<C, S, M, H>where
C: ConversationStore + 'static,
S: StateStore + 'static,
M: InputSender + 'static,
H: HttpClient + 'static,
impl<C, S, M, H> AgentSystemBuilder<C, S, M, H>where
C: ConversationStore + 'static,
S: StateStore + 'static,
M: InputSender + 'static,
H: HttpClient + 'static,
Sourcepub fn tool(self, tool: Box<dyn Tool<M>>) -> Self
pub fn tool(self, tool: Box<dyn Tool<M>>) -> Self
Register an additional tool (static configuration).
Sourcepub fn tools(self, tools: impl IntoIterator<Item = Box<dyn Tool<M>>>) -> Self
pub fn tools(self, tools: impl IntoIterator<Item = Box<dyn Tool<M>>>) -> Self
Register additional tools (static configuration).
Sourcepub fn extra_system_prompt(self, prompt: impl Into<String>) -> Self
pub fn extra_system_prompt(self, prompt: impl Into<String>) -> Self
Append text to the built-in system prompt (static configuration).
Sourcepub fn thread_config<H2: HttpClient + 'static>(
self,
source: impl ThreadConfigSource<M, H2> + 'static,
) -> AgentSystemBuilder<C, S, M, H2>
pub fn thread_config<H2: HttpClient + 'static>( self, source: impl ThreadConfigSource<M, H2> + 'static, ) -> AgentSystemBuilder<C, S, M, H2>
Resolve tools, prompt, and notifier dynamically per thread instead of
using the static tools/extra_system_prompt/rap_notifier
configuration (which must not be combined with a source). Use this
when threads need different toolsets — e.g. one session per working
directory, each with its own tool servers.
Sourcepub fn callback_url(self, url: impl Into<String>) -> Self
pub fn callback_url(self, url: impl Into<String>) -> Self
The base URL RAP tool servers should POST results to.
Sourcepub fn without_builtin_tools(self) -> Self
pub fn without_builtin_tools(self) -> Self
Do not register the built-in thread/subscription tools. Useful for systems that need a minimal or fully custom toolset.
Sourcepub fn with_tokio_sleep_tools(self) -> Self
pub fn with_tokio_sleep_tools(self) -> Self
Register timed sleep tools backed by in-process tokio timers
(sleep, sleep_until). Only suitable for resident runtimes; on
serverless platforms register durable-timer equivalents instead.
Sourcepub fn rap_notifier<H2: HttpClient + 'static>(
self,
notifier: RapNotifier<H2>,
) -> AgentSystemBuilder<C, S, M, H2>
pub fn rap_notifier<H2: HttpClient + 'static>( self, notifier: RapNotifier<H2>, ) -> AgentSystemBuilder<C, S, M, H2>
Configure the notifier that sends best-effort lifecycle notifications
(tool cancellation, thread closure) to RAP tool servers (static
configuration; with thread_config the
notifier comes from each thread’s ThreadConfig instead).
Sourcepub fn build(self) -> AgentSystem<C, S, M, H>
pub fn build(self) -> AgentSystem<C, S, M, H>
Build a step-mode system driven by an external transport.
Source§impl<C, S, M> AgentSystemBuilder<C, S, M, NoRapHttp>
impl<C, S, M> AgentSystemBuilder<C, S, M, NoRapHttp>
Sourcepub fn new(
conversation_store: C,
state_store: S,
model: impl ModelSource + 'static,
sender: M,
) -> Self
pub fn new( conversation_store: C, state_store: S, model: impl ModelSource + 'static, sender: M, ) -> Self
Start building a system whose loopback path is sender (the
platform’s own transport, e.g. SQS). Use
new_local for a self-contained
in-process system.
Source§impl<C, S> AgentSystemBuilder<C, S, ChannelSender, NoRapHttp>where
C: ConversationStore + 'static,
S: StateStore + 'static,
impl<C, S> AgentSystemBuilder<C, S, ChannelSender, NoRapHttp>where
C: ConversationStore + 'static,
S: StateStore + 'static,
Sourcepub fn new_local(
conversation_store: C,
state_store: S,
model: impl ModelSource + 'static,
) -> Self
pub fn new_local( conversation_store: C, state_store: S, model: impl ModelSource + 'static, ) -> Self
Start building a self-contained local system with an internal
in-process input queue. Tools should be registered against
ChannelSender.
Source§impl<C, S, H> AgentSystemBuilder<C, S, ChannelSender, H>
impl<C, S, H> AgentSystemBuilder<C, S, ChannelSender, H>
Sourcepub fn build_local(self) -> LocalAgentSystem<C, S, H>
pub fn build_local(self) -> LocalAgentSystem<C, S, H>
Build a local system without starting it. Most embeddings can call
start or
start_with_observer directly; use this
two-phase form when the built LocalAgentSystem must be held before
running it. Requires construction via
new_local.
Sourcepub fn start(self) -> LaunchingSystem<C, S, H>
pub fn start(self) -> LaunchingSystem<C, S, H>
Build the local system and start it with the built-in thread-builder
API: create threads through LaunchingSystem::thread_builder, and
reattach to existing threads with LaunchingSystem::thread_handle.
Shorthand for build_local() followed by
LocalAgentSystem::start. Requires construction via
new_local.
Sourcepub fn start_with_observer<O, F>(
self,
make_observer: F,
) -> RunningSystem<O::SubscribeRequest>
pub fn start_with_observer<O, F>( self, make_observer: F, ) -> RunningSystem<O::SubscribeRequest>
Build the local system and start it with a custom ThreadObserver.
Shorthand for build_local() followed by
LocalAgentSystem::start_with_observer, which documents the
observer contract. Requires construction via
new_local.