Skip to main content

AgentBuilder

Struct AgentBuilder 

Source
pub struct AgentBuilder { /* private fields */ }

Implementations§

Source§

impl AgentBuilder

Source

pub fn new() -> AgentBuilder

Source

pub fn from_spec(spec: AgentSpec) -> AgentBuilder

Source

pub fn from_yaml(yaml_content: &str) -> Result<AgentBuilder, AgentError>

Source

pub fn from_yaml_file( path: impl AsRef<Path>, ) -> Result<AgentBuilder, AgentError>

Source

pub fn from_template(template_name: &str) -> Result<AgentBuilder, AgentError>

Source

pub fn from_template_with_loader( template_name: &str, loader: &TemplateLoader, ) -> Result<AgentBuilder, AgentError>

Source

pub fn auto_configure_llms(self) -> Result<AgentBuilder, AgentError>

Source

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 registry

Wrong — built-ins are lost:

.tool(Arc::new(MyTool))       // self.tools = Some(empty + MyTool)
.auto_configure_features()?   // self.tools is Some -> skips builtin registration
Source

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.

Source

pub fn llm(self, llm: Arc<dyn LLMProvider>) -> AgentBuilder

Source

pub fn llm_alias( self, alias: impl Into<String>, provider: Arc<dyn LLMProvider>, ) -> AgentBuilder

Source

pub fn llm_registry(self, registry: LLMRegistry) -> AgentBuilder

Source

pub fn memory(self, memory: Arc<dyn Memory>) -> AgentBuilder

Source

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.

Source

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.

Source

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.

Source

pub fn skill(self, skill: SkillDefinition) -> AgentBuilder

Source

pub fn skills(self, skills: Vec<SkillDefinition>) -> AgentBuilder

Source

pub fn skill_loader(self, loader: SkillLoader) -> AgentBuilder

Source

pub fn system_prompt(self, prompt: impl Into<String>) -> AgentBuilder

Source

pub fn tools_prompt(self, prompt: impl Into<String>) -> AgentBuilder

Source

pub fn auto_tools_prompt(self, auto: bool) -> AgentBuilder

Source

pub fn max_iterations(self, max: u32) -> AgentBuilder

Source

pub fn max_context_tokens(self, tokens: u32) -> AgentBuilder

Source

pub fn recovery_manager(self, manager: RecoveryManager) -> AgentBuilder

Source

pub fn tool_security(self, engine: ToolSecurityEngine) -> AgentBuilder

Source

pub fn process_processor(self, processor: ProcessProcessor) -> AgentBuilder

Source

pub fn message_filter( self, name: impl Into<String>, filter: Arc<dyn MessageFilter>, ) -> AgentBuilder

Source

pub fn context_manager(self, manager: Arc<ContextManager>) -> AgentBuilder

Source

pub fn state_machine(self, machine: Arc<StateMachine>) -> AgentBuilder

Source

pub fn transition_evaluator( self, evaluator: Arc<dyn TransitionEvaluator>, ) -> AgentBuilder

Source

pub fn hooks(self, hooks: Arc<dyn AgentHooks>) -> AgentBuilder

Source

pub fn approval_handler(self, handler: Arc<dyn ApprovalHandler>) -> AgentBuilder

Source

pub fn hitl_engine(self, engine: HITLEngine) -> AgentBuilder

Source

pub fn storage_config(self, config: StorageConfig) -> AgentBuilder

Source

pub fn storage(self, storage: Arc<dyn AgentStorage>) -> AgentBuilder

Source

pub fn reasoning(self, config: ReasoningConfig) -> AgentBuilder

Source

pub fn reflection(self, config: ReflectionConfig) -> AgentBuilder

Source

pub fn persona(self, manager: Arc<PersonaManager>) -> AgentBuilder

Set persona config directly (overrides spec).

Source

pub fn persona_templates( self, registry: Arc<PersonaTemplateRegistry>, ) -> AgentBuilder

Provide a shared persona template registry.

Source

pub fn streaming(self, enabled: bool) -> AgentBuilder

Source

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().

Source

pub fn build(self) -> Result<RuntimeAgent, AgentError>

Trait Implementations§

Source§

impl Default for AgentBuilder

Source§

fn default() -> AgentBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more