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 tools(self, tools: ToolRegistry) -> Self
pub fn tools(self, tools: ToolRegistry) -> Self
Set the tool registry. Defaults to an empty ToolRegistry.
Sourcepub fn task_manager(self, manager: impl TaskManager + 'static) -> Self
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.
Sourcepub fn permissions(self, permissions: impl PermissionChecker + 'static) -> Self
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.
Sourcepub fn resources(self, resources: impl ToolResources + 'static) -> Self
pub fn resources(self, resources: impl ToolResources + 'static) -> Self
Set shared resources available to tool implementations.
Sourcepub fn cancellation(self, handle: CancellationHandle) -> Self
pub fn cancellation(self, handle: CancellationHandle) -> Self
Attach a CancellationHandle for cooperative cancellation of turns.
Sourcepub fn compaction(self, config: CompactionConfig) -> Self
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.
Sourcepub fn observer(self, observer: impl LoopObserver + 'static) -> Self
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.