pub struct AgentBuilder {
pub verification_gates: Vec<VerificationGate>,
/* 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.
Fields§
§verification_gates: Vec<VerificationGate>Optional workflow contract override. If absent, build creates an implicit contract.
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 preloaded_lua_tools(self, tools: ToolRegistry) -> Self
pub fn preloaded_lua_tools(self, tools: ToolRegistry) -> 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().
pub fn lua_tool_loader<F>(self, f: F) -> Self
Sourcepub fn run_policy(self, policy: RunPolicy) -> Self
pub fn run_policy(self, policy: RunPolicy) -> Self
Apply a per-run policy on top of the configured agent mode.
Sourcepub fn verification_gate(self, gate: VerificationGate) -> Self
pub fn verification_gate(self, gate: VerificationGate) -> Self
Add a verification gate to the agent run.
Sourcepub fn verification_gates<I>(self, gates: I) -> Selfwhere
I: IntoIterator<Item = VerificationGate>,
pub fn verification_gates<I>(self, gates: I) -> Selfwhere
I: IntoIterator<Item = VerificationGate>,
Add verification gates to the agent run.
Sourcepub fn verify_command(self, command: impl Into<String>, required: bool) -> Self
pub fn verify_command(self, command: impl Into<String>, required: bool) -> Self
Add a command verification gate to the agent run.
Sourcepub fn preloaded_prompt_context(self, context: SessionPromptContext) -> Self
pub fn preloaded_prompt_context(self, context: SessionPromptContext) -> Self
Use preloaded mana prompt context instead of loading it during build.
Sourcepub fn workflow_contract(self, contract: WorkflowContract) -> Self
pub fn workflow_contract(self, contract: WorkflowContract) -> Self
Override the implicit workflow contract for this agent run.
Sourcepub fn autonomy_mode(self, mode: AutonomyMode) -> Self
pub fn autonomy_mode(self, mode: AutonomyMode) -> Self
Set the autonomy mode on the implicit workflow contract.
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