pub struct AgentBuilder<B: LlmBackend> { /* private fields */ }Expand description
Fluent builder for Agent.
§Example
ⓘ
use agnt_core::AgentBuilder;
use my_backend::Backend;
let agent = AgentBuilder::new(Backend::ollama("gemma4:e4b"))
.system("You are a helpful assistant.")
.max_steps(5)
.max_window(20)
.max_tool_result_bytes(32 * 1024)
.on_token(Box::new(|tok| print!("{}", tok)))
.build();Implementations§
Source§impl<B: LlmBackend> AgentBuilder<B>
impl<B: LlmBackend> AgentBuilder<B>
Sourcepub fn new(backend: B) -> Self
pub fn new(backend: B) -> Self
Start a new builder with the given backend. The system prompt defaults
to the empty string and can be set with AgentBuilder::system.
Sourcepub fn max_steps(self, n: usize) -> Self
pub fn max_steps(self, n: usize) -> Self
Maximum inference turns per Agent::step call. Default: 10.
Sourcepub fn max_window(self, n: usize) -> Self
pub fn max_window(self, n: usize) -> Self
Maximum messages sent to the backend per turn. Default: 40.
Sourcepub fn max_tool_result_bytes(self, n: usize) -> Self
pub fn max_tool_result_bytes(self, n: usize) -> Self
Cap on raw bytes per tool result before envelope framing. Default: 64KB.
Sourcepub fn store(
self,
store: Arc<dyn MessageStore>,
session: impl Into<String>,
) -> Self
pub fn store( self, store: Arc<dyn MessageStore>, session: impl Into<String>, ) -> Self
Attach a persistent message store and session id.
Sourcepub fn on_token(self, sink: Box<dyn FnMut(&str) + Send>) -> Self
pub fn on_token(self, sink: Box<dyn FnMut(&str) + Send>) -> Self
Install a token callback. Each streamed delta from the backend is passed to this closure during inference.
Sourcepub fn max_step_duration(self, d: Duration) -> Self
pub fn max_step_duration(self, d: Duration) -> Self
Set a wall-clock deadline for a single Agent::step call.
See Agent::max_step_duration for the enforcement semantics.
Unset (the default) preserves the unbounded v0.3 behavior.
Auto Trait Implementations§
impl<B> Freeze for AgentBuilder<B>where
B: Freeze,
impl<B> !RefUnwindSafe for AgentBuilder<B>
impl<B> Send for AgentBuilder<B>
impl<B> !Sync for AgentBuilder<B>
impl<B> Unpin for AgentBuilder<B>where
B: Unpin,
impl<B> UnsafeUnpin for AgentBuilder<B>where
B: UnsafeUnpin,
impl<B> !UnwindSafe for AgentBuilder<B>
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
Mutably borrows from an owned value. Read more