Skip to main content

ResponseStepStore

Trait ResponseStepStore 

Source
pub trait ResponseStepStore: Send + Sync {
    // Required methods
    fn create_step<'life0, 'async_trait>(
        &'life0 self,
        input: CreateStepInput,
    ) -> Pin<Box<dyn Future<Output = Result<StepId>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_step<'life0, 'async_trait>(
        &'life0 self,
        id: StepId,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ResponseStep>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_step_by_request<'life0, 'async_trait>(
        &'life0 self,
        request_id: RequestId,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ResponseStep>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn list_chain<'life0, 'async_trait>(
        &'life0 self,
        head_step_id: StepId,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<ResponseStep>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn mark_step_processing<'life0, 'async_trait>(
        &'life0 self,
        id: StepId,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn complete_step<'life0, 'async_trait>(
        &'life0 self,
        id: StepId,
        response: Value,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn fail_step<'life0, 'async_trait>(
        &'life0 self,
        id: StepId,
        error: Value,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn cancel_step<'life0, 'async_trait>(
        &'life0 self,
        id: StepId,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn requeue_step_for_retry<'life0, 'async_trait>(
        &'life0 self,
        id: StepId,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Storage trait for response step persistence.

Mirrors the shape of crate::Storage for requests but scoped to the response_steps table. Implementations must be safe to call from multiple concurrent tasks within a single worker (tool fan-out within a single response holds the parent request lease, so no cross-worker coordination is required).

Required Methods§

Source

fn create_step<'life0, 'async_trait>( &'life0 self, input: CreateStepInput, ) -> Pin<Box<dyn Future<Output = Result<StepId>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Insert a new step in pending state.

No database-side idempotency constraint. Callers that need idempotent recovery should walk the chain first via ResponseStepStore::list_chain and skip emission of successors that already exist.

Source

fn get_step<'life0, 'async_trait>( &'life0 self, id: StepId, ) -> Pin<Box<dyn Future<Output = Result<Option<ResponseStep>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch a single step by id. Returns None if not present.

Source

fn get_step_by_request<'life0, 'async_trait>( &'life0 self, request_id: RequestId, ) -> Pin<Box<dyn Future<Output = Result<Option<ResponseStep>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch the step (if any) whose request_id matches the given fusillade request id. Used by analytics + outlet plumbing to resolve “which step does this upstream HTTP fire belong to”. Returns None for tool_call steps (which don’t carry a request_id) and for any non-multi-step fusillade row.

Source

fn list_chain<'life0, 'async_trait>( &'life0 self, head_step_id: StepId, ) -> Pin<Box<dyn Future<Output = Result<Vec<ResponseStep>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List every step in a response chain identified by its head step.

Includes the head itself + every descendant (parallel tool_calls and any future sub-agent recursion via prev_step_id branching). Ordered by step_sequence.

Source

fn mark_step_processing<'life0, 'async_trait>( &'life0 self, id: StepId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mark a pending step as processing, recording started_at.

Idempotent: if the step is already in a non-pending state the call returns Ok(()) without modifying the row, so crash recovery can resume safely.

Source

fn complete_step<'life0, 'async_trait>( &'life0 self, id: StepId, response: Value, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mark a step as completed with the given response_payload.

Source

fn fail_step<'life0, 'async_trait>( &'life0 self, id: StepId, error: Value, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mark a step as failed with the given structured error payload.

Source

fn cancel_step<'life0, 'async_trait>( &'life0 self, id: StepId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mark a step as canceled.

Source

fn requeue_step_for_retry<'life0, 'async_trait>( &'life0 self, id: StepId, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Increment a step’s retry_attempt and reset it to pending for re- firing under crash recovery. Used when a worker picks up a step that was left in processing by a dead worker.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§