Skip to main content

AgentStructuredExt

Trait AgentStructuredExt 

Source
pub trait AgentStructuredExt {
    // Required methods
    fn run_typed<T>(
        &self,
        session_id: &str,
        input: impl Into<Message> + Send,
    ) -> impl Future<Output = Result<TypedOutcome<T>, StructuredError>> + Send
       where T: DeserializeOwned + JsonSchema + Send;
    fn run_typed_from<T>(
        &self,
        state: RunState,
        cancel: CancellationToken,
    ) -> impl Future<Output = Result<TypedOutcome<T>, StructuredError>> + Send
       where T: DeserializeOwned + JsonSchema + Send;
    fn resume_typed<T>(
        &self,
        state: RunState,
        resolution: Resolution,
    ) -> impl Future<Output = Result<TypedOutcome<T>, StructuredError>> + Send
       where T: DeserializeOwned + JsonSchema + Send;
    fn finish_typed<T>(
        &self,
        outcome: RunOutcome,
    ) -> impl Future<Output = Result<TypedOutcome<T>, StructuredError>> + Send
       where T: DeserializeOwned + JsonSchema + Send;
}
Expand description

Final answers as your own type. Implemented for Agent.

Required Methods§

Source

fn run_typed<T>( &self, session_id: &str, input: impl Into<Message> + Send, ) -> impl Future<Output = Result<TypedOutcome<T>, StructuredError>> + Send

Agent::run, with the final answer read as T (one repair attempt). Tools still run as usual; only the final answer must match.

Source

fn run_typed_from<T>( &self, state: RunState, cancel: CancellationToken, ) -> impl Future<Output = Result<TypedOutcome<T>, StructuredError>> + Send

Agent::run_from (a saved, not interrupted state), typed.

Source

fn resume_typed<T>( &self, state: RunState, resolution: Resolution, ) -> impl Future<Output = Result<TypedOutcome<T>, StructuredError>> + Send

Agent::resume for a run started with AgentStructuredExt::run_typed, typed. May end StructuredError::NotFinished again at the next interruption.

Source

fn finish_typed<T>( &self, outcome: RunOutcome, ) -> impl Future<Output = Result<TypedOutcome<T>, StructuredError>> + Send

Read the final answer of an outcome you already have (for example after resuming an interrupted run) as T, with one repair attempt.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§