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,
impl<M> AgentBuilder<M>where
M: ModelAdapter,
Sourcepub fn model(self, model: M) -> AgentBuilder<M>
pub fn model(self, model: M) -> AgentBuilder<M>
Set the model adapter (required).
Sourcepub fn tools(self, tools: ToolRegistry) -> AgentBuilder<M>
pub fn tools(self, tools: ToolRegistry) -> AgentBuilder<M>
Set the tool registry. Defaults to an empty ToolRegistry.
Sourcepub fn task_manager(
self,
manager: impl TaskManager + 'static,
) -> AgentBuilder<M>
pub fn task_manager( self, manager: impl TaskManager + 'static, ) -> AgentBuilder<M>
Set the task manager that schedules tool-call execution.
Defaults to SimpleTaskManager, which preserves the existing
sequential request/response behavior.
Sourcepub fn permissions(
self,
permissions: impl PermissionChecker + 'static,
) -> AgentBuilder<M>
pub fn permissions( self, permissions: impl PermissionChecker + 'static, ) -> AgentBuilder<M>
Set the permission checker that gates tool execution.
Defaults to allowing all tool calls without prompting.
Sourcepub fn resources(
self,
resources: impl ToolResources + 'static,
) -> AgentBuilder<M>
pub fn resources( self, resources: impl ToolResources + 'static, ) -> AgentBuilder<M>
Set shared resources available to tool implementations.
Sourcepub fn cancellation(self, handle: CancellationHandle) -> AgentBuilder<M>
pub fn cancellation(self, handle: CancellationHandle) -> AgentBuilder<M>
Attach a CancellationHandle for cooperative cancellation of turns.
Sourcepub fn compaction(self, config: CompactionConfig) -> AgentBuilder<M>
pub fn compaction(self, config: CompactionConfig) -> AgentBuilder<M>
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.
Sourcepub fn observer(self, observer: impl LoopObserver + 'static) -> AgentBuilder<M>
pub fn observer(self, observer: impl LoopObserver + 'static) -> AgentBuilder<M>
Register a LoopObserver that receives AgentEvents.
Multiple observers may be registered; they are called in order.