pub trait AgentChannel: Send + Sync {
// Required methods
fn start_session(
&self,
req: StartSessionRequest,
) -> AgentFuture<Result<SessionRef, AgentError>>;
fn run_turn(
&self,
session_id: String,
req: TurnRequest,
events: UnboundedSender<TurnEvent>,
) -> AgentFuture<Result<TurnResult, AgentError>>;
fn shutdown_session(
&self,
session_id: String,
) -> AgentFuture<Result<(), AgentError>>;
}Expand description
Provider-agnostic session channel for executing agent turns.
Implementations bridge a specific transport - CLI subprocess or app-server
RPC - to the unified TurnEvent stream consumed by session workers. The
trait is object-safe so it can be held as Arc<dyn AgentChannel>.
Required Methods§
Sourcefn start_session(
&self,
req: StartSessionRequest,
) -> AgentFuture<Result<SessionRef, AgentError>>
fn start_session( &self, req: StartSessionRequest, ) -> AgentFuture<Result<SessionRef, AgentError>>
Initialises a provider session for the given session identifier.
Implementations that do not maintain persistent sessions return
immediately with a SessionRef wrapping the supplied identifier.
Sourcefn run_turn(
&self,
session_id: String,
req: TurnRequest,
events: UnboundedSender<TurnEvent>,
) -> AgentFuture<Result<TurnResult, AgentError>>
fn run_turn( &self, session_id: String, req: TurnRequest, events: UnboundedSender<TurnEvent>, ) -> AgentFuture<Result<TurnResult, AgentError>>
Executes one prompt turn and streams incremental events to events.
Implementations may emit TurnEvent::ThoughtDelta values for
transient loader updates. Final transcript output is derived from the
returned TurnResult after the turn finishes.
§Errors
Returns AgentError when the turn cannot be executed (spawn failure,
transport error) or is interrupted by a signal.
Sourcefn shutdown_session(
&self,
session_id: String,
) -> AgentFuture<Result<(), AgentError>>
fn shutdown_session( &self, session_id: String, ) -> AgentFuture<Result<(), AgentError>>
Tears down the provider session associated with session_id.
Implementations that do not maintain persistent sessions treat this as
a no-op and always return Ok(()).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".