pub struct AgentBuilder { /* private fields */ }Implementations§
Source§impl AgentBuilder
impl AgentBuilder
Sourcepub fn new(provider: Arc<dyn LlmProvider>) -> Self
pub fn new(provider: Arc<dyn LlmProvider>) -> Self
Create a new builder with an LlmProvider.
Sourcepub fn with_tool_activation(self, activation: ToolActivation) -> Self
pub fn with_tool_activation(self, activation: ToolActivation) -> Self
Share the session’s tool-activation set with the engine. See the field
docs: a product that registers crate::tool::ActivateTool must hand
that tool this same set.
Sourcepub fn defer_tool(&mut self, name: &str) -> Option<Value>
pub fn defer_tool(&mut self, name: &str) -> Option<Value>
Re-wrap a registered tool as crate::tool::DeferredTool: it stays on
the roster and is callable once opened, but costs the request nothing
until then.
Returns the tool’s rendered wire definition, which is what
crate::tool::ActivateTool hands back when the model opens it. The
product needs that here because the tools worth deferring are built
inside the framework’s own builder — it never holds the instances, so
it cannot render them itself. None when the name is not registered.
Registration-time wrapping would be cleaner if every tool were built where the product can see it. This moves the call to the product all the same, which is the only layer that knows what its work actually needs.
pub fn event_bus_capacity(self, capacity: usize) -> Self
pub fn session_id_generator( self, generator: Arc<dyn SessionIdGenerator>, ) -> Self
Sourcepub fn convert_to_llm(self, cb: ConvertToLlmFn) -> Self
pub fn convert_to_llm(self, cb: ConvertToLlmFn) -> Self
Set a callback to transform messages before they are sent to the LLM.
The default behavior (when None) is to filter out
ChatMessage::Custom variants, which most providers don’t understand.
Override this to inject custom serialization logic for application-specific
message types.
pub fn guard(self, guard: impl ReactLoopGuard + 'static) -> Self
Sourcepub fn guard_dyn(self, guard: Arc<dyn ReactLoopGuard>) -> Self
pub fn guard_dyn(self, guard: Arc<dyn ReactLoopGuard>) -> Self
Set a guard from a pre-built Arc<dyn ReactLoopGuard>.
Use this when you need to share the guard reference (e.g. for inspecting recorded calls in tests).
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.
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 (T10c): text turns route to it, tool-envelope turns keep the built-in 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, sdk-assembly §3.4).
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 (FailClosedInteract) — 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 —
phimint’s TUI shape). Unset = DEFAULT_INTERACT_TIMEOUT.
Sourcepub fn get_guard(&self) -> Option<&Arc<dyn ReactLoopGuard>>
pub fn get_guard(&self) -> Option<&Arc<dyn ReactLoopGuard>>
Check if a guard has been set.
Used by agent-works to inject a default guard if none was set.
pub fn system_prompt(self, system_prompt: impl Into<String>) -> Self
Sourcepub fn enable_thought(self, enable: bool) -> Self
pub fn enable_thought(self, enable: bool) -> Self
Set whether to include the reasoning content in LLM responses.
Controls whether the reasoning_content field from the LLM is forwarded
to consumers (i.e., “show the thinking process”).
See AgentConfig::enable_thought for the distinction from enable_thinking().
pub fn reasoning(self, config: ReasoningConfig) -> Self
Sourcepub fn enable_thinking(self, enable: bool) -> Self
pub fn enable_thinking(self, enable: bool) -> Self
Set whether to enable the model’s extended thinking / reasoning mode.
Controls whether the model performs deep reasoning (i.e., “enable thinking mode”).
See AgentConfig::enable_thought for the distinction from enable_thought().
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 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 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 max_sessions(self, max: usize) -> Self
pub fn max_turns_per_session(self, max: usize) -> Self
Sourcepub fn execution_max_turns(self, max: u32) -> Self
pub fn execution_max_turns(self, max: u32) -> Self
Cap the number of react-loop iterations allowed for a single run (one user
input). Distinct from Self::max_turns_per_session, which caps turns across
the whole session. When unset, falls back to DEFAULT_MAX_TURNS (50).