pub struct Agent { /* private fields */ }Expand description
One configured model-tool agent.
Implementations§
Source§impl Agent
impl Agent
Sourcepub fn run<'a>(
&'a self,
input: impl Into<String> + Send + 'a,
run: &'a RunContext,
) -> AgentFuture<'a, Result<AgentOutcome, AgentError>>
pub fn run<'a>( &'a self, input: impl Into<String> + Send + 'a, run: &'a RunContext, ) -> AgentFuture<'a, Result<AgentOutcome, AgentError>>
Runs a user text turn inside an existing runtime context.
Sourcepub fn stream<'a>(
&'a self,
input: impl Into<String> + Send + 'a,
run: &'a RunContext,
) -> AgentEventStream<'a>
pub fn stream<'a>( &'a self, input: impl Into<String> + Send + 'a, run: &'a RunContext, ) -> AgentEventStream<'a>
Streams real-time events while driving the canonical Agent loop.
Sourcepub fn run_checkpointed<'a>(
&'a self,
input: impl Into<String> + Send + 'a,
run: &'a RunContext,
checkpoint: &'a AgentCheckpoint,
) -> AgentFuture<'a, Result<AgentOutcome, AgentError>>
pub fn run_checkpointed<'a>( &'a self, input: impl Into<String> + Send + 'a, run: &'a RunContext, checkpoint: &'a AgentCheckpoint, ) -> AgentFuture<'a, Result<AgentOutcome, AgentError>>
Runs with write-ahead checkpoint persistence.
Sourcepub fn resume<'a>(
&'a self,
checkpoint: &'a AgentCheckpoint,
run: &'a RunContext,
policy: ResumePolicy,
) -> AgentFuture<'a, Result<AgentOutcome, AgentError>>
pub fn resume<'a>( &'a self, checkpoint: &'a AgentCheckpoint, run: &'a RunContext, policy: ResumePolicy, ) -> AgentFuture<'a, Result<AgentOutcome, AgentError>>
Resumes a persisted Agent execution.
Source§impl Agent
impl Agent
Sourcepub fn builder(
name: impl Into<String>,
model: Arc<dyn Model>,
model_ref: ModelRef,
) -> AgentBuilder
pub fn builder( name: impl Into<String>, model: Arc<dyn Model>, model_ref: ModelRef, ) -> AgentBuilder
Starts a fluent builder for an Agent.
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 an agent without instructions or tools.
Sourcepub fn tools(self, tools: ToolRegistry) -> Self
pub fn tools(self, tools: ToolRegistry) -> Self
Installs the registry whose tools are exposed and executable.
Sourcepub fn agents(self, agents: AgentGateway) -> Self
pub fn agents(self, agents: AgentGateway) -> Self
Installs the gateway whose child agents are exposed and callable.
Sourcepub fn effect_executor(self, effects: EffectExecutor) -> Self
pub fn effect_executor(self, effects: EffectExecutor) -> Self
Replaces the write-ahead effect coordinator shared by callables.
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 const fn with_config(self, config: AgentConfig) -> Self
pub const fn with_config(self, config: AgentConfig) -> Self
Replaces local execution configuration.
Sourcepub fn output_format(self, output_format: OutputFormat) -> Self
pub fn output_format(self, output_format: OutputFormat) -> Self
Sets the desired format for the terminal model response.
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 fn into_structured<T>(self, name: impl Into<String>) -> StructuredAgent<T>where
T: JsonSchema,
pub fn into_structured<T>(self, name: impl Into<String>) -> StructuredAgent<T>where
T: JsonSchema,
Binds provider schema generation and local decoding to the same type.
Sourcepub const fn model_ref(&self) -> &ModelRef
pub const fn model_ref(&self) -> &ModelRef
Returns the provider and model identity used by this Agent.
Sourcepub fn callable_capabilities(&self) -> CapabilitySet
pub fn callable_capabilities(&self) -> CapabilitySet
Returns capabilities for every Tool and child Agent exposed by this Agent.
The returned set is not granted automatically. Applications explicitly decide whether to install it on a root or delegated Run.