Skip to main content

BoundDef

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

pub fn state<T>(self, value: Arc<T>) -> BoundDef
where T: Send + Sync + 'static,

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

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
where I: IntoIterator<Item = S>, S: Into<String>,

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

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

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

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

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

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

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

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

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

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

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>

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

Trait Implementations§

§

impl Debug for BoundDef

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> ServiceExt for T

§

fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>
where Self: Sized,

Apply a transformation to the response body. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more