Skip to main content

Agent

Struct Agent 

Source
pub struct Agent { /* private fields */ }
Expand description

One configured model-tool agent.

Implementations§

Source§

impl Agent

Source

pub fn prompt<'a>( &'a self, input: impl Into<String> + Send + 'a, ) -> AgentFuture<'a, Result<AgentOutcome, AgentError>>

Runs a user text turn with a default root context.

This is the ergonomic surface for one-off prompts. It grants only callables registered on this Agent and applies no hard budget limit. Use Self::run when the caller must provide explicit authority, budget, deadline, observability, or run-tree identity.

Source

pub fn prompt_text<'a>( &'a self, input: impl Into<String> + Send + 'a, ) -> AgentFuture<'a, Result<String, AgentError>>

Runs an ergonomic prompt and returns only model-visible text.

Rich content, usage, warnings, the canonical transcript, and provider events are intentionally discarded. Use Self::prompt when that information matters.

Source

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.

Source

pub fn run_conversation<'a>( &'a self, input: impl Into<String> + Send + 'a, run: &'a RunContext, store: &'a dyn ConversationStore, conversation_id: ConversationId, namespace: MemoryNamespace, policy: ConversationContextPolicy, ) -> AgentFuture<'a, Result<AgentConversationOutcome, AgentConversationError>>

Runs and atomically commits one bounded multi-turn conversation.

Transcript messages remain append-only. Execution-journal events stay in runifold_core::Journal, summaries remain lossy derived views, and semantic memory is injected only as explicitly untrusted context.

Source

pub fn run_conversation_with_summary<'a>( &'a self, input: impl Into<String> + Send + 'a, run: &'a RunContext, store: &'a dyn ConversationStore, conversation_id: ConversationId, namespace: MemoryNamespace, automatic_summary: AutomaticConversationSummary<'a>, ) -> AgentFuture<'a, Result<AgentConversationOutcome, AgentConversationError>>

Summarizes an overflowing prefix before running a conversational turn.

Summary generation uses the supplied AutomaticConversationSummary and the same RunContext, preserving cancellation, deadline, budget, and journal behavior. The immutable transcript is never rewritten.

Source

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.

Source

pub fn run_durable_conversation<'a>( &'a self, input: impl Into<String> + Send + 'a, run: &'a RunContext, store: Arc<dyn DurableConversationStore>, request: DurableConversationRequest, ) -> AgentFuture<'a, Result<AgentConversationOutcome, AgentConversationError>>

Runs one conversational turn with atomic transcript and checkpoint commit.

Intermediate checkpoints are written ahead of model and callable work. The terminal checkpoint and transcript append are committed together by DurableConversationStore.

Source

pub fn resume_durable_conversation<'a>( &'a self, store: Arc<dyn DurableConversationStore>, checkpoint_id: CheckpointId, run: &'a RunContext, policy: ResumePolicy, ) -> AgentFuture<'a, Result<AgentConversationOutcome, AgentConversationError>>

Resumes a durable conversational turn from its write-ahead checkpoint.

Source

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.

Source

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

Source

pub fn builder( name: impl Into<String>, model: Arc<dyn Model>, model_ref: ModelRef, ) -> AgentBuilder

Starts a fluent builder for an Agent.

Source

pub fn new( name: impl Into<String>, model: Arc<dyn Model>, model_ref: ModelRef, ) -> Self

Creates an agent without instructions or tools.

Source

pub fn system(self, instruction: impl Into<String>) -> Self

Appends a system instruction.

Source

pub fn tools(self, tools: ToolRegistry) -> Self

Installs the registry whose tools are exposed and executable.

Source

pub fn agents(self, agents: AgentGateway) -> Self

Installs the gateway whose child agents are exposed and callable.

Source

pub fn effect_executor(self, effects: EffectExecutor) -> Self

Replaces the write-ahead effect coordinator shared by callables.

Source

pub const fn effect_recovery_policy(self, policy: EffectRecoveryPolicy) -> Self

Sets recovery behavior for ambiguous callable effects.

Source

pub const fn with_config(self, config: AgentConfig) -> Self

Replaces local execution configuration.

Source

pub const fn min_successful_tool_calls(self, minimum: u32) -> Self

Requires this many successful local Tool calls before terminal output.

Failed Tool results, child-Agent delegations, provider-hosted Tools, and Tool results from earlier conversation turns do not satisfy this execution-local completion contract. A value of zero disables it.

Source

pub fn output_format(self, output_format: OutputFormat) -> Self

Sets the desired format for the terminal model response.

Source

pub fn structured_output<T>(self, name: impl Into<String>) -> Self
where T: JsonSchema,

Requests strict structured output described by the Rust type T.

Source

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.

Source

pub fn name(&self) -> &str

Returns the stable local agent name.

Source

pub const fn model_ref(&self) -> &ModelRef

Returns the provider and model identity used by this Agent.

Source

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.

Source

pub fn default_run_context(&self) -> RunContext

Creates a root context for the ergonomic prompt surface.

The context has no hard budget limits and grants only the Tool and child Agent capabilities explicitly registered on this Agent. Applications that need deadlines, tighter budgets, narrower authority, durable journals, or shared run trees should construct a RunContext and use Self::run instead.

Trait Implementations§

Source§

impl Clone for Agent

Source§

fn clone(&self) -> Agent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ConversationSummarizer for Agent

Source§

fn summarize<'a>( &'a self, request: ConversationSummaryRequest, run: &'a RunContext, ) -> ConversationSummarizerFuture<'a, Result<String, ConversationSummarizerError>>

Rolls a previously committed summary forward over immutable entries.
Source§

impl Debug for Agent

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Agent

§

impl !UnwindSafe for Agent

§

impl Freeze for Agent

§

impl Send for Agent

§

impl Sync for Agent

§

impl Unpin for Agent

§

impl UnsafeUnpin for Agent

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.