pub struct AgentBuilder { /* private fields */ }Implementations§
Source§impl AgentBuilder
impl AgentBuilder
pub fn new() -> Self
pub fn from_spec(spec: AgentSpec) -> Self
Sourcepub fn from_spec_with_base_dir(
spec: AgentSpec,
base_dir: impl Into<PathBuf>,
) -> Self
pub fn from_spec_with_base_dir( spec: AgentSpec, base_dir: impl Into<PathBuf>, ) -> Self
Builds from an existing spec while resolving relative resources from the supplied directory.
pub fn from_yaml(yaml_content: &str) -> Result<Self>
pub fn from_yaml_file(path: impl AsRef<Path>) -> Result<Self>
pub fn from_template(template_name: &str) -> Result<Self>
pub fn from_template_with_loader( template_name: &str, loader: &TemplateLoader, ) -> Result<Self>
pub fn auto_configure_llms(self) -> Result<Self>
Sourcepub fn auto_configure_features(self) -> Result<Self>
pub fn auto_configure_features(self) -> Result<Self>
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<Self>
pub async fn auto_configure_mcp(self) -> Result<Self>
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>) -> Self
pub fn llm_alias( self, alias: impl Into<String>, provider: Arc<dyn LLMProvider>, ) -> Self
Sourcepub fn llm_registry(self, registry: LLMRegistry) -> Self
pub fn llm_registry(self, registry: LLMRegistry) -> Self
Set a raw LLM registry that may still need observability wrapping.
pub fn memory(self, memory: Arc<dyn Memory>) -> Self
Sourcepub fn tools(self, tools: ToolRegistry) -> Self
pub fn tools(self, tools: ToolRegistry) -> Self
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>) -> Self
pub fn tool(self, tool: Arc<dyn Tool>) -> Self
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) -> Self
pub fn extend_tools(self, additional: ToolRegistry) -> Self
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) -> Self
pub fn skills(self, skills: Vec<SkillDefinition>) -> Self
pub fn skill_loader(self, loader: SkillLoader) -> Self
pub fn system_prompt(self, prompt: impl Into<String>) -> Self
pub fn tools_prompt(self, prompt: impl Into<String>) -> Self
pub fn auto_tools_prompt(self, auto: bool) -> Self
pub fn max_iterations(self, max: u32) -> Self
pub fn max_context_tokens(self, tokens: u32) -> Self
pub fn recovery_manager(self, manager: RecoveryManager) -> Self
pub fn tool_security(self, engine: ToolSecurityEngine) -> Self
pub fn process_processor(self, processor: ProcessProcessor) -> Self
pub fn message_filter( self, name: impl Into<String>, filter: Arc<dyn MessageFilter>, ) -> Self
pub fn context_manager(self, manager: Arc<ContextManager>) -> Self
pub fn state_machine(self, machine: Arc<StateMachine>) -> Self
pub fn transition_evaluator( self, evaluator: Arc<dyn TransitionEvaluator>, ) -> Self
pub fn hooks(self, hooks: Arc<dyn AgentHooks>) -> Self
pub fn approval_handler(self, handler: Arc<dyn ApprovalHandler>) -> Self
pub fn hitl_engine(self, engine: HITLEngine) -> Self
pub fn storage_config(self, config: StorageConfig) -> Self
pub fn storage(self, storage: Arc<dyn AgentStorage>) -> Self
pub fn reasoning(self, config: ReasoningConfig) -> Self
pub fn reflection(self, config: ReflectionConfig) -> Self
Sourcepub fn persona(self, manager: Arc<PersonaManager>) -> Self
pub fn persona(self, manager: Arc<PersonaManager>) -> Self
Set persona config directly (overrides spec).
Sourcepub fn persona_templates(self, registry: Arc<PersonaTemplateRegistry>) -> Self
pub fn persona_templates(self, registry: Arc<PersonaTemplateRegistry>) -> Self
Provide a shared persona template registry.
Sourcepub fn observability(self, manager: Arc<ObservabilityManager>) -> Self
pub fn observability(self, manager: Arc<ObservabilityManager>) -> Self
Provide a shared observability manager instead of creating one from YAML.
pub fn streaming(self, enabled: bool) -> Self
Sourcepub async fn auto_configure_spawner(self) -> Result<Self>
pub async fn auto_configure_spawner(self) -> Result<Self>
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>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AgentBuilder
impl !RefUnwindSafe for AgentBuilder
impl !UnwindSafe for AgentBuilder
impl Send for AgentBuilder
impl Sync for AgentBuilder
impl Unpin for AgentBuilder
impl UnsafeUnpin 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