pub struct AgentBuilder { /* private fields */ }Expand description
Builder for creating a fully wired Agent from config and context.
Handles resource discovery, hook loading, system prompt assembly, and tool registration so callers don’t need to repeat this boilerplate.
Implementations§
Source§impl AgentBuilder
impl AgentBuilder
Sourcepub fn new(config: Config, cwd: PathBuf, model: Model, api_key: String) -> Self
pub fn new(config: Config, cwd: PathBuf, model: Model, api_key: String) -> Self
Create a new builder.
Sourcepub fn task(self, task: TaskContext) -> Self
pub fn task(self, task: TaskContext) -> Self
Set the task context (headless/task mode — Layer 5 of the system prompt).
Sourcepub fn facts(self, facts: Vec<Fact>) -> Self
pub fn facts(self, facts: Vec<Fact>) -> Self
Set task-specific facts to inject into the system prompt.
Sourcepub fn system_prompt(self, prompt: String) -> Self
pub fn system_prompt(self, prompt: String) -> Self
Override the assembled system prompt with a custom string. When set, resource discovery and assembly are skipped.
Sourcepub fn extra_tools<F>(self, f: F) -> Self
pub fn extra_tools<F>(self, f: F) -> Self
Register additional tools after the native tools are registered.
Sourcepub fn lua_tool_loader<F>(self, f: F) -> Self
pub fn lua_tool_loader<F>(self, f: F) -> Self
Register a Lua extension tool loader.
The provided closure should discover .lua extensions, create a
LuaRuntime, and register the resulting tools onto the registry.
This is called after native + extra tools are registered but before
mode filtering.
The binary crate typically calls this with a closure that invokes
imp_lua::load_lua_extensions().
Sourcepub fn build(self) -> Result<(Agent, AgentHandle)>
pub fn build(self) -> Result<(Agent, AgentHandle)>
Build the agent, wiring config → thresholds, hooks, resources, and tools.
Returns (Agent, AgentHandle) ready for use.
Auto Trait Implementations§
impl Freeze for AgentBuilder
impl !RefUnwindSafe for AgentBuilder
impl Send for AgentBuilder
impl !Sync for AgentBuilder
impl Unpin for AgentBuilder
impl UnsafeUnpin for AgentBuilder
impl !UnwindSafe for AgentBuilder
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> 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 more