pub struct AgentBuilder<P: Provider> { /* private fields */ }Expand description
Builder for creating agents
Implementations§
Source§impl<P: Provider> AgentBuilder<P>
impl<P: Provider> AgentBuilder<P>
Sourcepub fn system_prompt(self, prompt: impl Into<String>) -> Self
pub fn system_prompt(self, prompt: impl Into<String>) -> Self
Set the system prompt
Sourcepub fn temperature(self, temp: f64) -> Self
pub fn temperature(self, temp: f64) -> Self
Set the temperature
Sourcepub fn max_tokens(self, tokens: u64) -> Self
pub fn max_tokens(self, tokens: u64) -> Self
Set max tokens
Sourcepub fn extra_params(self, params: Value) -> Self
pub fn extra_params(self, params: Value) -> Self
Add extra provider-specific parameters
Sourcepub fn tool_policy(self, policy: RiskyToolPolicy) -> Self
pub fn tool_policy(self, policy: RiskyToolPolicy) -> Self
Set tool policy
Sourcepub fn approval_handler(self, handler: impl ApprovalHandler + 'static) -> Self
pub fn approval_handler(self, handler: impl ApprovalHandler + 'static) -> Self
Set external approval handler
Sourcepub fn interaction_handler(
self,
handler: impl InteractionHandler + 'static,
) -> Self
pub fn interaction_handler( self, handler: impl InteractionHandler + 'static, ) -> Self
Set interaction handler (for HITL)
Sourcepub fn max_history_messages(self, count: usize) -> Self
pub fn max_history_messages(self, count: usize) -> Self
Set max history messages (sliding window)
Sourcepub fn max_tool_output_chars(self, count: usize) -> Self
pub fn max_tool_output_chars(self, count: usize) -> Self
Set max tool output characters
Sourcepub fn json_mode(self, enable: bool) -> Self
pub fn json_mode(self, enable: bool) -> Self
Enable strict JSON mode (enforces response_format: json_object)
Sourcepub fn session_id(self, id: impl Into<String>) -> Self
pub fn session_id(self, id: impl Into<String>) -> Self
Set session ID for persistence
Sourcepub fn context_injector(self, injector: impl ContextInjector + 'static) -> Self
pub fn context_injector(self, injector: impl ContextInjector + 'static) -> Self
Add a context injector
Add a shared tool
Sourcepub fn with_memory(self, memory: Arc<dyn Memory>) -> Self
pub fn with_memory(self, memory: Arc<dyn Memory>) -> Self
Add memory tools using the provided memory implementation
Sourcepub fn with_dynamic_skills(self, skill_loader: Arc<SkillLoader>) -> Result<Self>
pub fn with_dynamic_skills(self, skill_loader: Arc<SkillLoader>) -> Result<Self>
Add DynamicSkill support (ClawHub skills, custom scripts)
§Security
CRITICAL: DynamicSkill and Python Sidecar are mutually exclusive. This method will return an error if Python Sidecar has already been configured.
Rationale: If both are enabled, malicious DynamicSkills can pollute the Agent’s context with secrets, which may then be used by LLM-generated Python code in the unsandboxed Sidecar to exfiltrate data.
See SECURITY.md for details.
Sourcepub async fn with_code_interpreter(
self,
address: impl Into<String>,
) -> Result<Self>
pub async fn with_code_interpreter( self, address: impl Into<String>, ) -> Result<Self>
Add code interpreter capability using the given sidecar address
§Security
CRITICAL: Python Sidecar and DynamicSkill are mutually exclusive. This method will return an error if DynamicSkill has already been configured.
Rationale: Python Sidecar has no sandbox isolation. If DynamicSkill is also enabled, malicious skills can pollute the Agent’s context, leading to secret exfiltration via LLM-generated Python code in the Sidecar.
See SECURITY.md for details.
Sourcepub fn build(self) -> Result<Agent<P>>
pub fn build(self) -> Result<Agent<P>>
Build the agent
§Security Defaults
If neither Python Sidecar nor DynamicSkill has been explicitly configured, this method will automatically enable DynamicSkill with default settings:
- Skills directory:
./skills - Network access: disabled (secure sandbox)
To use Python Sidecar instead, call .with_code_interpreter() before .build().
Sourcepub fn with_delegation(self, coordinator: Arc<Coordinator>) -> Self
pub fn with_delegation(self, coordinator: Arc<Coordinator>) -> Self
Add delegation support using the provided coordinator
Sourcepub fn with_scheduler(self, scheduler: Arc<Scheduler>) -> Self
pub fn with_scheduler(self, scheduler: Arc<Scheduler>) -> Self
Add scheduling support using the provided scheduler
Sourcepub fn with_swarm(
self,
manager: Arc<Mutex<SwarmManager>>,
cmd_rx: Receiver<SwarmEvent>,
) -> Self
pub fn with_swarm( self, manager: Arc<Mutex<SwarmManager>>, cmd_rx: Receiver<SwarmEvent>, ) -> Self
Enable dynamic swarming capabilities
Auto Trait Implementations§
impl<P> Freeze for AgentBuilder<P>where
P: Freeze,
impl<P> !RefUnwindSafe for AgentBuilder<P>
impl<P> Send for AgentBuilder<P>
impl<P> Sync for AgentBuilder<P>
impl<P> Unpin for AgentBuilder<P>where
P: Unpin,
impl<P> !UnwindSafe for AgentBuilder<P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request