Skip to main content

AgentBuilder

Struct AgentBuilder 

Source
pub struct AgentBuilder<M>
where M: ModelAdapter,
{ /* private fields */ }
Expand description

Builder for constructing an Agent.

Obtained via Agent::builder. The only required field is model; all others have sensible defaults (no tools, allow-all permissions, no compaction, no observers).

Implementations§

Source§

impl<M> AgentBuilder<M>
where M: ModelAdapter,

Source

pub fn model(self, model: M) -> Self

Set the model adapter (required).

Source

pub fn tools(self, tools: ToolRegistry) -> Self

Set the tool registry. Defaults to an empty ToolRegistry.

Source

pub fn task_manager(self, manager: impl TaskManager + 'static) -> Self

Set the task manager that schedules tool-call execution.

Defaults to SimpleTaskManager, which preserves the existing sequential request/response behavior.

Source

pub fn permissions(self, permissions: impl PermissionChecker + 'static) -> Self

Set the permission checker that gates tool execution.

Defaults to allowing all tool calls without prompting.

Source

pub fn resources(self, resources: impl ToolResources + 'static) -> Self

Set shared resources available to tool implementations.

Source

pub fn cancellation(self, handle: CancellationHandle) -> Self

Attach a CancellationHandle for cooperative cancellation of turns.

Source

pub fn compaction(self, config: CompactionConfig) -> Self

Enable transcript compaction with the given configuration.

When configured, the driver checks the compaction trigger before each turn and applies the compaction strategy if the transcript is too long.

Source

pub fn observer(self, observer: impl LoopObserver + 'static) -> Self

Register a LoopObserver that receives AgentEvents.

Multiple observers may be registered; they are called in order.

Source

pub fn build(self) -> Result<Agent<M>, LoopError>

Consume the builder and produce an Agent.

§Errors

Returns LoopError::InvalidState if no model adapter was provided.

Trait Implementations§

Source§

impl<M> Default for AgentBuilder<M>
where M: ModelAdapter,

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<M> Freeze for AgentBuilder<M>
where M: Freeze,

§

impl<M> !RefUnwindSafe for AgentBuilder<M>

§

impl<M> Send for AgentBuilder<M>

§

impl<M> !Sync for AgentBuilder<M>

§

impl<M> Unpin for AgentBuilder<M>
where M: Unpin,

§

impl<M> UnsafeUnpin for AgentBuilder<M>
where M: UnsafeUnpin,

§

impl<M> !UnwindSafe for AgentBuilder<M>

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, 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, 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.