pub struct AgentBuilder { /* private fields */ }Expand description
Fluent assembly of one canonical Agent.
Registration failures are retained and returned by Self::build so
Tool and child Agent calls remain chainable without silently replacing an
existing name.
Implementations§
Source§impl AgentBuilder
impl AgentBuilder
Sourcepub fn new(
name: impl Into<String>,
model: Arc<dyn Model>,
model_ref: ModelRef,
) -> Self
pub fn new( name: impl Into<String>, model: Arc<dyn Model>, model_ref: ModelRef, ) -> Self
Creates a builder around the same execution path as Agent::new.
Registers a shared, type-erased Tool.
Sourcepub fn child(
self,
descriptor: AgentDescriptor,
child: Arc<Agent>,
capabilities: CapabilitySet,
) -> Self
pub fn child( self, descriptor: AgentDescriptor, child: Arc<Agent>, capabilities: CapabilitySet, ) -> Self
Registers a child Agent route with explicit delegated capabilities.
Sourcepub fn gateway_layer(self, middleware: Arc<dyn GatewayMiddleware>) -> Self
pub fn gateway_layer(self, middleware: Arc<dyn GatewayMiddleware>) -> Self
Appends Gateway around-middleware.
Sourcepub fn max_delegation_depth(self, max_depth: u32) -> Self
pub fn max_delegation_depth(self, max_depth: u32) -> Self
Sets the maximum nested Agent delegation depth.
Sourcepub const fn tool_error_policy(self, policy: ToolErrorPolicy) -> Self
pub const fn tool_error_policy(self, policy: ToolErrorPolicy) -> Self
Sets Tool failure behavior.
Sourcepub const fn feature_policy(self, policy: FeaturePolicy) -> Self
pub const fn feature_policy(self, policy: FeaturePolicy) -> Self
Sets provider feature-degradation behavior.
Sourcepub fn output_format(self, output_format: OutputFormat) -> Self
pub fn output_format(self, output_format: OutputFormat) -> Self
Sets the desired terminal model-output format.
Sourcepub fn structured_output<T>(self, name: impl Into<String>) -> Selfwhere
T: JsonSchema,
pub fn structured_output<T>(self, name: impl Into<String>) -> Selfwhere
T: JsonSchema,
Requests strict structured output described by the Rust type T.
Sourcepub const fn config(self, config: AgentConfig) -> Self
pub const fn config(self, config: AgentConfig) -> Self
Replaces all local Agent configuration.
Sourcepub fn effect_executor(self, effects: EffectExecutor) -> Self
pub fn effect_executor(self, effects: EffectExecutor) -> Self
Shares a write-ahead effect coordinator with this Agent.
Sourcepub const fn effect_recovery_policy(self, policy: EffectRecoveryPolicy) -> Self
pub const fn effect_recovery_policy(self, policy: EffectRecoveryPolicy) -> Self
Sets recovery behavior for ambiguous callable effects.
Sourcepub fn build(self) -> Result<Agent, AgentBuildError>
pub fn build(self) -> Result<Agent, AgentBuildError>
Validates registrations and returns the canonical Agent.
§Errors
Returns AgentBuildError for blank identity, invalid turn bounds,
duplicate registrations, or Tool/Agent name collisions.
Sourcepub fn build_structured<T>(
self,
name: impl Into<String>,
) -> Result<StructuredAgent<T>, AgentBuildError>where
T: JsonSchema,
pub fn build_structured<T>(
self,
name: impl Into<String>,
) -> Result<StructuredAgent<T>, AgentBuildError>where
T: JsonSchema,
Builds an Agent whose schema and local decoder are bound to T.
This is the preferred terminal builder operation for structured output because a different decode type cannot be selected later by mistake.
§Errors
Returns AgentBuildError under the same validation rules as
Self::build.