Skip to main content

AppServerClient

Trait AppServerClient 

Source
pub trait AppServerClient: Send + Sync {
    // Required methods
    fn run_turn(
        &self,
        request: AppServerTurnRequest,
        stream_tx: UnboundedSender<AppServerStreamEvent>,
    ) -> AppServerFuture<Result<AppServerTurnResponse, AppServerError>>;
    fn shutdown_session(&self, session_id: String) -> AppServerFuture<()>;

    // Provided methods
    fn run_isolated_turn<'client>(
        &'client self,
        request: AppServerTurnRequest,
        stream_tx: UnboundedSender<AppServerStreamEvent>,
    ) -> Pin<Box<dyn Future<Output = Result<AppServerTurnResponse, AppServerError>> + Send + 'client>> { ... }
    fn run_retained_turn(
        &self,
        request: AppServerTurnRequest,
        stream_tx: UnboundedSender<AppServerStreamEvent>,
    ) -> AppServerFuture<Result<AppServerTurnResponse, AppServerError>> { ... }
}
Expand description

Persistent app-server session boundary used by session workers.

Required Methods§

Source

fn run_turn( &self, request: AppServerTurnRequest, stream_tx: UnboundedSender<AppServerStreamEvent>, ) -> AppServerFuture<Result<AppServerTurnResponse, AppServerError>>

Executes one prompt turn for a session and returns normalized output. Implementations must charge provider_call_budget before each underlying provider attempt, including restart retries.

Intermediate events (agent messages, progress updates) are sent through stream_tx as they arrive, enabling the caller to display streaming output before the turn completes.

Source

fn shutdown_session(&self, session_id: String) -> AppServerFuture<()>

Stops and forgets a session runtime, if one exists.

Provided Methods§

Source

fn run_isolated_turn<'client>( &'client self, request: AppServerTurnRequest, stream_tx: UnboundedSender<AppServerStreamEvent>, ) -> Pin<Box<dyn Future<Output = Result<AppServerTurnResponse, AppServerError>> + Send + 'client>>

Runs with fresh conversation context, reusing the process when the provider supports resetting context. The fallback restarts the runtime. It waits for shutdown to finish before invoking run_turn, borrowing the client until the returned future completes or is dropped. Callers must omit provider conversation IDs and replay context.

Source

fn run_retained_turn( &self, request: AppServerTurnRequest, stream_tx: UnboundedSender<AppServerStreamEvent>, ) -> AppServerFuture<Result<AppServerTurnResponse, AppServerError>>

Continues the current conversation and retains a successful runtime for later pooled submissions. Clients without pooling support fall back to their ordinary turn lifecycle.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§