Struct BoundDef
pub struct BoundDef { /* private fields */ }Expand description
An agent definition whose tools are bound and whose prompts are rendered, waiting for the
state its tools need and for a model. Made by AgentDef::bind.
AgentDef::from_manifest(&AGENT)?.bind(tools![..])?.state(env).model(model, "alias")?Implementations§
§impl BoundDef
impl BoundDef
pub fn state<T>(self, value: Arc<T>) -> BoundDef
pub fn state<T>(self, value: Arc<T>) -> BoundDef
Share value with the tools of every agent, as
LlmAgentBuilder::state does: tools read it with ctx.state::<T>(), and
model fails when a tool declares a state that nobody gave.
pub fn tool_source(self, source: impl ToolSource) -> BoundDef
pub fn tool_source(self, source: impl ToolSource) -> BoundDef
Give every agent a ToolSource: tools it learns about while it runs, offered to the model
at every turn after the agent’s own tools (LlmAgentBuilder::tool_source). The sources are
asked in the order they were added. An agent’s tools: does not narrow them (they are not
known when the files are read), so a deployment gives a source only the tools it wants an agent
to have.
pub fn model_aliases<I, S>(self, aliases: I) -> BoundDef
pub fn model_aliases<I, S>(self, aliases: I) -> BoundDef
The model aliases this deployment serves. With this set, model refuses
an agent whose model: (or the default alias) is not one of them, and suggests the
closest. Without it any alias is accepted and a wrong one fails on the first model call.
pub fn model_profiles(self, profiles: ModelProfiles) -> BoundDef
pub fn model_profiles(self, profiles: ModelProfiles) -> BoundDef
The deployment’s per-model profiles (ADR 0063, ADR 0064): what each model takes as a
reasoning effort, which preset it starts from, and its output cap. model
resolves each agent’s default effort from its folder, its model_preset, the profile and
the profile’s preset, and refuses a value the model does not take; it resolves the cap the
same way (then 128,000) and clamps it to the model’s limit and window. Without them no model
has a profile, so an agent that sets an effort is refused, one that sets none sends none, and
every cap is the folder’s or 128,000.
pub fn allow_model_choice(self) -> BoundDef
pub fn allow_model_choice(self) -> BoundDef
Let a message pick the model of its run among the deployment’s profiles
(MODEL_CONTEXT_KEY, ADR 0064 amended 2026-11-23):
every agent is given a binding, with its cap and reasoning level, for each model that has a
profile (model_profiles). Off by default: a served agent’s callers
may not choose what a run costs, so the key is ignored there. The engine turns it on.
pub fn wait_poll(self, every: Duration) -> BoundDef
pub fn wait_poll(self, every: Duration) -> BoundDef
How long an agent that waits for something (a subagent’s child run, the task of a remote
subagent) sleeps between looks: LlmAgentBuilder::wait_poll, for every agent. The default
is the loop’s, 60 seconds. A child run tells its parent when it is done, so the timer is
only its fallback; a remote subagent has no such message, so this is how often its task
is looked at, and the longest a finished remote task waits to be noticed.
pub fn max_parallel(self, n: usize) -> BoundDef
pub fn max_parallel(self, n: usize) -> BoundDef
The most tool calls of one model turn that run at the same time, for every agent: the
deployment’s MAX_PARALLEL_TOOL_CALLS (LlmAgentBuilder::max_parallel, 1 to 32; the
loop’s default is 10). An agent’s file may lower it for that agent with
limits.max_parallel; a larger value in a file is clamped to the deployment’s, with a
warning (ADR 0049, ADR 0054 decision 3), so a folder stays usable under a deployment that
allows less.
pub fn model_parking(self, parking: ModelParking) -> BoundDef
pub fn model_parking(self, parking: ModelParking) -> BoundDef
How every agent waits on a model that refused it or could not be reached
(LlmAgentBuilder::model_parking, ADR 0067): the deployment’s MODEL_PARK_LIMIT, and
whether an unreachable endpoint parks (MODEL_AUTH=injector). Without it the loop’s
default: a limit of 24 hours, and an unreachable endpoint that fails the run.
pub fn admission(self, admission: Arc<dyn Admission>) -> BoundDef
pub fn admission(self, admission: Arc<dyn Admission>) -> BoundDef
The process’s pools ([adam_budget::Admission], ADR 0065): every agent built here asks it
for every model call and every tool call. Without one, nothing is admitted.
pub fn step_io(self, step_io: StepIo) -> BoundDef
pub fn step_io(self, step_io: StepIo) -> BoundDef
How the step of a tool call reports its input and output, for every agent:
LlmAgentBuilder::step_io. A deployment that holds secrets gives the redactor that knows
them here (StepIo::redact); without it, both are sent as the model and the tool had them,
cut to the contract’s bounds.
pub fn hooks(self, hooks: HookSet) -> BoundDef
pub fn hooks(self, hooks: HookSet) -> BoundDef
The host’s own hooks (ADR 0050), for every agent built here, the root and each subagent:
they run first, in their order and under the set’s limits, then the plugins the agent’s file
names in plugins: (AgentDef::plugin). A host that must be asked
before a tool runs (an application that embeds the engine, ADR 0047 slice 5) gives the plugin
here, so no agent file can leave it out. AgentInfo::plugins lists the file’s plugins only.
Calling this again replaces the set.
pub fn scrub(
self,
scrub: impl Fn(&str) -> String + Send + Sync + 'static,
) -> BoundDef
pub fn scrub( self, scrub: impl Fn(&str) -> String + Send + Sync + 'static, ) -> BoundDef
Scrub secrets out of what the tools that run a subagent in the background give the model:
the report of a session, and every error. The five session tools (subagent_start and the
others, given to an agent that has subagents) are made here, not by the deployment, so the
deployment’s own wrapper around its tools never sees them; this is the same hook for them,
and scrub is what that wrapper would apply (the coder’s redactor). Without it the report is
given as the subagent wrote it. The function is applied to a text and must return the same
text with its secrets replaced.
pub fn scrub_longest(
self,
longest: impl Fn() -> usize + Send + Sync + 'static,
) -> BoundDef
pub fn scrub_longest( self, longest: impl Fn() -> usize + Send + Sync + 'static, ) -> BoundDef
How long, in bytes, the longest value scrub replaces is (the coder’s
Redactor::longest): the session tools’ ToolCtx::scrub_margin
is then the same as for the deployment’s own tools. A session report is a text a child wrote,
scrubbed whole; it is never a cut text, so no open edge is kept back for it.
pub fn model(
self,
model: Arc<dyn ModelClient>,
alias: impl Into<String>,
) -> Result<Assembly, Error>
pub fn model( self, model: Arc<dyn ModelClient>, alias: impl Into<String>, ) -> Result<Assembly, Error>
Give the agents their model and build them.
model is the one client every agent talks to (the composition root’s endpoint), and
alias is the gateway alias of an agent that names none. An agent uses, in this order,
the alias its model: names, the alias of its parent when it says inherit (a
subagent’s default), and alias (the root’s).
§Errors
Error::ModelAliasfor an alias that is empty, has whitespace, or is not one ofmodel_aliases;Error::UnknownModelPreset,Error::InvalidReasoningEffortorError::ReasoningEffortwhen the effort an agent resolves to is not one of its model’s levels (model_profiles);Error::OutputCapwhen a preset itsmodel_presetnames asks for more output tokens than the model documents;Error::Buildwhen a tool needs state thatstatedid not give.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for BoundDef
impl !UnwindSafe for BoundDef
impl Freeze for BoundDef
impl Send for BoundDef
impl Sync for BoundDef
impl Unpin for BoundDef
impl UnsafeUnpin for BoundDef
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].