pub struct AgentBuilder { /* private fields */ }Implementations§
Source§impl AgentBuilder
impl AgentBuilder
pub fn new() -> AgentBuilder
pub fn from_spec(spec: AgentSpec) -> AgentBuilder
pub fn from_yaml(yaml_content: &str) -> Result<AgentBuilder, AgentError>
pub fn from_yaml_file( path: impl AsRef<Path>, ) -> Result<AgentBuilder, AgentError>
pub fn from_template(template_name: &str) -> Result<AgentBuilder, AgentError>
pub fn from_template_with_loader( template_name: &str, loader: &TemplateLoader, ) -> Result<AgentBuilder, AgentError>
pub fn auto_configure_llms(self) -> Result<AgentBuilder, AgentError>
Sourcepub fn auto_configure_features(self) -> Result<AgentBuilder, AgentError>
pub fn auto_configure_features(self) -> Result<AgentBuilder, AgentError>
Auto-configure recovery, tool security, process pipeline, and built-in tools from the spec.
Call order matters for tools: this method only registers built-in tools when self.tools is None.
If .tool() or .tools() was called before this, self.tools is already Some and built-ins will NOT be added.
Correct:
.auto_configure_features()? // registers built-ins (self.tools was None)
.tool(Arc::new(MyTool)) // adds MyTool into the builtin registryWrong — built-ins are lost:
.tool(Arc::new(MyTool)) // self.tools = Some(empty + MyTool)
.auto_configure_features()? // self.tools is Some -> skips builtin registrationSourcepub async fn auto_configure_mcp(self) -> Result<AgentBuilder, AgentError>
pub async fn auto_configure_mcp(self) -> Result<AgentBuilder, AgentError>
Initialize MCP wrapper tools from tools: entries with type: mcp.
Each MCP entry becomes an MCPWrapperTool registered as a normal builtin
tool in the ToolRegistry. Views defined in the entry’s views: field are registered as separate MCPViewTool instances sharing the parent’s MCP connection.
Call this after auto_configure_features() so the tool registry exists.
pub fn llm(self, llm: Arc<dyn LLMProvider>) -> AgentBuilder
pub fn llm_alias( self, alias: impl Into<String>, provider: Arc<dyn LLMProvider>, ) -> AgentBuilder
pub fn llm_registry(self, registry: LLMRegistry) -> AgentBuilder
pub fn memory(self, memory: Arc<dyn Memory>) -> AgentBuilder
Sourcepub fn tools(self, tools: ToolRegistry) -> AgentBuilder
pub fn tools(self, tools: ToolRegistry) -> AgentBuilder
Replace the entire tool registry.
If auto_configure_features() was called before this, the auto-registered builtins will be overwritten.
Sourcepub fn tool(self, tool: Arc<dyn Tool>) -> AgentBuilder
pub fn tool(self, tool: Arc<dyn Tool>) -> AgentBuilder
Register a single tool into the existing registry.
If no registry exists yet, creates an empty one first. Use this to add custom tools on top of auto-configured builtins.
Sourcepub fn extend_tools(self, additional: ToolRegistry) -> AgentBuilder
pub fn extend_tools(self, additional: ToolRegistry) -> AgentBuilder
Merge tools from another registry into the existing one.
Skips tools whose ID already exists (no overwrite). If no registry exists yet, creates an empty one first.
pub fn skill(self, skill: SkillDefinition) -> AgentBuilder
pub fn skills(self, skills: Vec<SkillDefinition>) -> AgentBuilder
pub fn skill_loader(self, loader: SkillLoader) -> AgentBuilder
pub fn system_prompt(self, prompt: impl Into<String>) -> AgentBuilder
pub fn tools_prompt(self, prompt: impl Into<String>) -> AgentBuilder
pub fn auto_tools_prompt(self, auto: bool) -> AgentBuilder
pub fn max_iterations(self, max: u32) -> AgentBuilder
pub fn max_context_tokens(self, tokens: u32) -> AgentBuilder
pub fn recovery_manager(self, manager: RecoveryManager) -> AgentBuilder
pub fn tool_security(self, engine: ToolSecurityEngine) -> AgentBuilder
pub fn process_processor(self, processor: ProcessProcessor) -> AgentBuilder
pub fn message_filter( self, name: impl Into<String>, filter: Arc<dyn MessageFilter>, ) -> AgentBuilder
pub fn context_manager(self, manager: Arc<ContextManager>) -> AgentBuilder
pub fn state_machine(self, machine: Arc<StateMachine>) -> AgentBuilder
pub fn transition_evaluator( self, evaluator: Arc<dyn TransitionEvaluator>, ) -> AgentBuilder
pub fn hooks(self, hooks: Arc<dyn AgentHooks>) -> AgentBuilder
pub fn approval_handler(self, handler: Arc<dyn ApprovalHandler>) -> AgentBuilder
pub fn hitl_engine(self, engine: HITLEngine) -> AgentBuilder
pub fn storage_config(self, config: StorageConfig) -> AgentBuilder
pub fn storage(self, storage: Arc<dyn AgentStorage>) -> AgentBuilder
pub fn reasoning(self, config: ReasoningConfig) -> AgentBuilder
pub fn reflection(self, config: ReflectionConfig) -> AgentBuilder
Sourcepub fn persona(self, manager: Arc<PersonaManager>) -> AgentBuilder
pub fn persona(self, manager: Arc<PersonaManager>) -> AgentBuilder
Set persona config directly (overrides spec).
Sourcepub fn persona_templates(
self,
registry: Arc<PersonaTemplateRegistry>,
) -> AgentBuilder
pub fn persona_templates( self, registry: Arc<PersonaTemplateRegistry>, ) -> AgentBuilder
Provide a shared persona template registry.
pub fn streaming(self, enabled: bool) -> AgentBuilder
Sourcepub async fn auto_configure_spawner(self) -> Result<AgentBuilder, AgentError>
pub async fn auto_configure_spawner(self) -> Result<AgentBuilder, AgentError>
Wire spawner tools when the spec has a spawner: section.
Call after auto_configure_llms() and auto_configure_features().
pub fn build(self) -> Result<RuntimeAgent, AgentError>
Trait Implementations§
Source§impl Default for AgentBuilder
impl Default for AgentBuilder
Source§fn default() -> AgentBuilder
fn default() -> AgentBuilder
Auto Trait Implementations§
impl !Freeze for AgentBuilder
impl !RefUnwindSafe for AgentBuilder
impl Send for AgentBuilder
impl Sync for AgentBuilder
impl Unpin for AgentBuilder
impl UnsafeUnpin for AgentBuilder
impl !UnwindSafe for AgentBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more