pub struct ReActAgentBuilder { /* private fields */ }Expand description
Builder for assembling a ReActAgent from the same components used by
ReActAgent::new, plus optional runtime configuration.
The builder is only an assembly helper: provider calls still go through
the agent loop, immediate tools still run through the tool registry, and
governed side effects still belong to the outer harness/kernel path.
Skill assembly is handled by the molo-skills layer so ReActAgent
does not own skill policy.
§Examples
use molo::{Agent, FakeProvider, FakeReply, ReActAgent};
let mut agent = ReActAgent::builder(FakeProvider::new([
FakeReply::Text("Hello".into()),
]))
.with_system_prompt("You are a helpful assistant")
.build();
assert_eq!(agent.run("Are you there").await?, "Hello");Implementations§
Source§impl ReActAgentBuilder
impl ReActAgentBuilder
Sourcepub fn new(provider: impl Provider + 'static) -> ReActAgentBuilder
pub fn new(provider: impl Provider + 'static) -> ReActAgentBuilder
Starts a builder with a provider and default optional components.
Sourcepub fn with_provider(
self,
provider: impl Provider + 'static,
) -> ReActAgentBuilder
pub fn with_provider( self, provider: impl Provider + 'static, ) -> ReActAgentBuilder
Replaces the provider.
Sourcepub fn with_tools(self, tools: ToolRegistry) -> ReActAgentBuilder
pub fn with_tools(self, tools: ToolRegistry) -> ReActAgentBuilder
Replaces the tool registry.
Sourcepub fn with_tool(self, tool: impl Tool + 'static) -> ReActAgentBuilder
pub fn with_tool(self, tool: impl Tool + 'static) -> ReActAgentBuilder
Registers one tool into the builder’s registry.
Sourcepub fn with_system_prompt(
self,
system_prompt: impl Into<String>,
) -> ReActAgentBuilder
pub fn with_system_prompt( self, system_prompt: impl Into<String>, ) -> ReActAgentBuilder
Sets the system prompt. Empty means no system message is assembled.
Sourcepub fn with_memory(self, memory: impl Memory + 'static) -> ReActAgentBuilder
pub fn with_memory(self, memory: impl Memory + 'static) -> ReActAgentBuilder
Replaces the default Memory.
Sourcepub fn with_config(self, config: AgentConfig) -> ReActAgentBuilder
pub fn with_config(self, config: AgentConfig) -> ReActAgentBuilder
Replaces the agent config.
Sourcepub fn with_structured_output(self, schema: Value) -> ReActAgentBuilder
pub fn with_structured_output(self, schema: Value) -> ReActAgentBuilder
Enables structured output for Agent::run.
Sourcepub fn with_state(self, state: SharedState) -> ReActAgentBuilder
pub fn with_state(self, state: SharedState) -> ReActAgentBuilder
Attaches shared state for tool calls.
Sourcepub fn with_event_channel(
self,
channel: impl EventChannel + 'static,
) -> ReActAgentBuilder
pub fn with_event_channel( self, channel: impl EventChannel + 'static, ) -> ReActAgentBuilder
Attaches an observation channel.
Sourcepub fn with_tool_round_executor(
self,
executor: impl ToolRoundExecutor + 'static,
) -> ReActAgentBuilder
pub fn with_tool_round_executor( self, executor: impl ToolRoundExecutor + 'static, ) -> ReActAgentBuilder
Replaces the tool-round executor.
Sourcepub fn build(self) -> ReActAgent
pub fn build(self) -> ReActAgent
Builds the agent.