pub struct AgentBuilder { /* private fields */ }Implementations§
Source§impl AgentBuilder
impl AgentBuilder
pub fn build(self) -> AgentResult<AgentRuntime>
Source§impl AgentBuilder
impl AgentBuilder
pub fn new(client: Arc<dyn LlmProvider>) -> Self
pub fn system_prompt(self, prompt: impl Into<String>) -> Self
pub fn enable_thought(self, enable: bool) -> Self
pub fn reasoning(self, config: ReasoningConfig) -> Self
pub fn enable_thinking(self, enable: bool) -> Self
pub fn thinking_budget(self, budget: u64) -> Self
pub fn tool_timeout(self, timeout_ms: u64) -> Self
pub fn max_tool_output_chars(self, max_chars: usize) -> Self
pub fn max_sessions(self, max: usize) -> Self
pub fn max_turns_per_session(self, max: usize) -> Self
pub fn execution_max_turns(self, max: u32) -> Self
pub fn max_message_tokens(self, max: usize) -> Self
pub fn register_tool(self, tool: impl Tool + 'static) -> Self
pub fn register_tool_arc(self, tool: Arc<dyn Tool>) -> Self
pub fn approval_handler(self, handler: Arc<dyn ApprovalHandler>) -> Self
pub fn tool_policy(self, policy: Arc<dyn ToolPolicy>) -> Self
pub fn middleware(self, mw: impl Middleware + 'static) -> Self
pub fn guard(self, guard: impl ReactLoopGuard + 'static) -> Self
Sourcepub fn action_backend(self, backend: Box<dyn ActionBackend>) -> Self
pub fn action_backend(self, backend: Box<dyn ActionBackend>) -> Self
Mount this runtime’s action backend (M3 T10c): text turns route to it, tool-envelope turns keep the tool-call backend. One backend per runtime — build one runtime per session when the backend holds a resident engine (the product’s assembly-time choice).
Sourcepub fn interaction(self, channel: Arc<dyn InteractionChannel>) -> Self
pub fn interaction(self, channel: Arc<dyn InteractionChannel>) -> Self
The product’s interaction surface for the action backend’s ExecCtx
(OV-6): consent and ask_user suspend through it. Without one, every
interaction fails closed — a cell reaching for the human refuses, it
never hangs or silently allows.
Sourcepub fn interaction_timeout(self, interact_timeout: Option<Duration>) -> Self
pub fn interaction_timeout(self, interact_timeout: Option<Duration>) -> Self
Per-interaction deadline for the action backend’s suspensions (None
= unbounded human time, the run’s cancel token is the only guard).
Unset = the kernel’s default watchdog.
pub fn context_window(self, max_tokens: usize) -> Self
pub fn context_window_manager(self, manager: ContextWindowManager) -> Self
pub fn response_format(self, format: ResponseFormat) -> Self
pub fn llm_retry(self, retry: RetryConfig) -> Self
pub fn session_store(self, store: Arc<dyn SessionStore>) -> Self
pub fn error_recovery(self, recovery: Arc<dyn ToolErrorRecovery>) -> Self
pub fn tool_error_retry_prompt(self, prompt: impl Into<String>) -> Self
pub fn language(self, language: Language) -> Self
Sourcepub fn context_compactor(self, compactor: Arc<dyn ContextCompaction>) -> Self
pub fn context_compactor(self, compactor: Arc<dyn ContextCompaction>) -> Self
Set an inline context compactor for the react loop.
When set, the react loop will check token count after each tool turn and compact the session if it exceeds the configured threshold.
pub fn event_bus_capacity(self, capacity: usize) -> Self
pub fn session_id_generator( self, generator: Arc<dyn SessionIdGenerator>, ) -> Self
Sourcepub fn apply_if<T>(
self,
value: Option<T>,
f: impl FnOnce(Self, T) -> Self,
) -> Self
pub fn apply_if<T>( self, value: Option<T>, f: impl FnOnce(Self, T) -> Self, ) -> Self
Conditionally apply a transformation when value is Some.
This is a convenience for option-chaining builder patterns:
builder.apply_if(args.thinking_budget, |b, budget| b.thinking_budget(budget))Sourcepub fn agent_instructions_paths(self, paths: Vec<PathBuf>) -> Self
pub fn agent_instructions_paths(self, paths: Vec<PathBuf>) -> Self
Set paths to agent instruction files (e.g., CLAUDE.md, INSTRUCTIONS.md).
These files are read at build time and appended to the system prompt. Supports multiple paths (user-level + project-level); later entries have higher priority and appear first in the prompt.
Example:
use std::path::PathBuf;
use agent_works::AgentBuilder;
let builder = AgentBuilder::new();
let builder = builder.agent_instructions_paths(vec![
PathBuf::from("~/.claude/CLAUDE.md"), // user-level
PathBuf::from(".claude/CLAUDE.md"), // project-level
]);