Skip to main content

AgentBuilder

Struct AgentBuilder 

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

Fluent builder for constructing AgentDefinition instances.

Implementations§

Source§

impl AgentBuilder

Source

pub fn with_name(self, name: impl Into<String>) -> Self

Sets the agent display name.

Source

pub fn with_version(self, version: impl Into<String>) -> Self

Sets the agent version string used for versioned transport routes.

Source

pub fn with_description(self, description: impl Into<String>) -> Self

Sets the agent description.

Source

pub fn with_dispatcher_prompt(self, prompt: impl Into<String>) -> Self

Sets the dispatcher prompt used by the runtime negotiator.

Source

pub fn with_skill<T>(self, skill: T) -> Self
where T: RegisteredSkill + 'static,

Registers a programmatic Rust skill with the agent.

The skill must implement RegisteredSkill, typically derived by the #[skill] macro.

Source

pub fn with_skill_def(self, def: AgentSkillDef) -> Self

Registers an AgentSkill from an AgentSkillDef.

Use [include_skill!] to create one at compile time (SKILL.md embedded into the binary), or AgentSkillDef::from_dir for runtime loading.

The LLM handler is injected when [Runtime::builder] calls build().

§Examples
// Compile-time — skill embedded in binary, no I/O at startup
Agent::builder()
    .with_skill_def(include_skill!("./skills/pdf-processing"))
    .build()
Source

pub fn with_skill_dir(self, path: impl AsRef<Path>) -> Result<Self, AgentError>

Load and register an AgentSkill from a directory at runtime.

Reads SKILL.md from the given directory, validates it against the AgentSkills specification, and queues it for handler injection when Runtime::builder(...).build() is called.

§Errors

Returns an error if the directory cannot be read, SKILL.md is missing, the frontmatter is invalid, or the name field doesn’t match the directory name.

§Examples
Agent::builder()
    .with_skill_dir("./skills/translate")?
    .build()
Source

pub fn build(self) -> AgentDefinition

Finalizes and returns the agent definition.

Note: if you have registered AgentSkills via [with_skill_def] or [with_skill_dir], pass this builder to [Runtime::builder] rather than calling build() directly — the runtime injects the LLM into AgentSkill handlers during its own build().

Trait Implementations§

Source§

impl From<AgentDefinition> for AgentBuilder

Source§

fn from(def: AgentDefinition) -> Self

Wraps a pre-built AgentDefinition in an AgentBuilder.

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSync for T
where T: Sync + ?Sized,

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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, 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<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