Skip to main content

DurableRunStore

Trait DurableRunStore 

Source
pub trait DurableRunStore: Send + Sync {
    // Required methods
    fn enqueue<'life0, 'async_trait>(
        &'life0 self,
        run: NewRun,
    ) -> Pin<Box<dyn Future<Output = Result<Enqueued, AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn claim<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        queue: &'life1 str,
        worker: &'life2 str,
        ttl: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ClaimedRun>, AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
    fn heartbeat<'life0, 'life1, 'async_trait>(
        &'life0 self,
        run_id: &'life1 str,
        epoch: u64,
        ttl: Duration,
    ) -> Pin<Box<dyn Future<Output = Result<bool, AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn set_checkpoint<'life0, 'life1, 'async_trait>(
        &'life0 self,
        run_id: &'life1 str,
        epoch: u64,
        checkpoint: RunCheckpointRef,
    ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn wait<'life0, 'life1, 'async_trait>(
        &'life0 self,
        run_id: &'life1 str,
        epoch: u64,
        until: Option<DateTime<Utc>>,
    ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn wake<'life0, 'life1, 'async_trait>(
        &'life0 self,
        run_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn finish<'life0, 'life1, 'async_trait>(
        &'life0 self,
        run_id: &'life1 str,
        epoch: u64,
        outcome: RunOutcome,
    ) -> Pin<Box<dyn Future<Output = Result<RunRecord, AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn request_cancel<'life0, 'life1, 'async_trait>(
        &'life0 self,
        run_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        run_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<RunRecord>, AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn list<'life0, 'async_trait>(
        &'life0 self,
        filter: RunFilter,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<RunRecord>, AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn prune<'life0, 'async_trait>(
        &'life0 self,
        finished_before: DateTime<Utc>,
    ) -> Pin<Box<dyn Future<Output = Result<u64, AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
}
Expand description

Core traits and types.

Always available regardless of feature flags. Includes:

  • Agent - The fundamental trait for all agents
  • Tool / Toolset - For extending agents with capabilities
  • Session / State - For managing conversation context
  • Event - For streaming agent responses
  • AdkError / Result - Unified error handling The durable queue of runs.

Named DurableRunStore so it does not clash with adk_server::background::RunStore, the server’s process-local record of background runs.

Every backend passes adk_core::run_store_conformance_tests! (feature conformance). The module documentation lists the lifecycle and the primitive each backend uses for each guarantee.

Required Methods§

Source

fn enqueue<'life0, 'async_trait>( &'life0 self, run: NewRun, ) -> Pin<Box<dyn Future<Output = Result<Enqueued, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Adds a run.

An existing run with the same (queue, idempotency_key) is returned as Enqueued::Existing before any concurrency check. Concurrent enqueues of one key create exactly one run.

§Errors

Returns INVALID_RUN_CODE when NewRun::validate fails.

Source

fn claim<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, queue: &'life1 str, worker: &'life2 str, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<Option<ClaimedRun>, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Claims the oldest claimable run in queue for worker with a lease of ttl.

Claimable, oldest enqueued first: a Queued run whose not_before passed and that no earlier unfinished run with its concurrency key precedes; a Waiting run whose wait ended or that was woken; a Running run whose lease expired (recovery). The run’s epoch increases by one on every claim. Concurrent claims never return the same run at the same epoch.

§Errors

Returns run_store.invalid_ttl for a zero ttl.

Source

fn heartbeat<'life0, 'life1, 'async_trait>( &'life0 self, run_id: &'life1 str, epoch: u64, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<bool, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Extends the lease to ttl from now and returns whether cancellation was requested.

§Errors

Returns RUN_STALE_EPOCH_CODE when the run is not Running at epoch, and RUN_NOT_FOUND_CODE for an unknown run.

Source

fn set_checkpoint<'life0, 'life1, 'async_trait>( &'life0 self, run_id: &'life1 str, epoch: u64, checkpoint: RunCheckpointRef, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Records where the run’s progress is checkpointed.

§Errors

Same as heartbeat.

Source

fn wait<'life0, 'life1, 'async_trait>( &'life0 self, run_id: &'life1 str, epoch: u64, until: Option<DateTime<Utc>>, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Releases the lease and parks the run until until passes or wake is called. None parks it until woken.

§Errors

Same as heartbeat.

Source

fn wake<'life0, 'life1, 'async_trait>( &'life0 self, run_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Makes a Waiting run claimable now; records a pending wake for a Running run; does nothing for a queued or finished run.

§Errors

Returns RUN_NOT_FOUND_CODE for an unknown run.

Source

fn finish<'life0, 'life1, 'async_trait>( &'life0 self, run_id: &'life1 str, epoch: u64, outcome: RunOutcome, ) -> Pin<Box<dyn Future<Output = Result<RunRecord, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Ends the attempt with outcome and returns the updated run.

Failed { retryable: true } requeues the run while attempt < max_attempts and no cancellation was requested; every other outcome is terminal.

§Errors

Same as heartbeat.

Source

fn request_cancel<'life0, 'life1, 'async_trait>( &'life0 self, run_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Cancels a queued or waiting run, or flags a running one for its worker to stop. A finished run is left unchanged.

§Errors

Returns RUN_NOT_FOUND_CODE for an unknown run.

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, run_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<RunRecord>, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Returns a run, or None when it does not exist or was pruned.

Source

fn list<'life0, 'async_trait>( &'life0 self, filter: RunFilter, ) -> Pin<Box<dyn Future<Output = Result<Vec<RunRecord>, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Returns the runs matching filter, oldest enqueued first.

Source

fn prune<'life0, 'async_trait>( &'life0 self, finished_before: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<u64, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Deletes finished runs whose updated_at is before finished_before and returns how many were deleted. Their idempotency keys become free again.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§