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>>;
// Provided method
fn steer_turn(
&self,
session_id: String,
prompt: TurnPrompt,
) -> 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.
Dropping the returned future must release its owned execution resources;
cancellation callers will not poll the future again to drain it.
§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.
Cancellation must be idempotent and must never start an unpolled turn. Implementations release persistent resources or cancel active CLI turns.
Provided Methods§
Sourcefn steer_turn(
&self,
session_id: String,
prompt: TurnPrompt,
) -> AgentFuture<Result<(), AgentError>>
fn steer_turn( &self, session_id: String, prompt: TurnPrompt, ) -> AgentFuture<Result<(), AgentError>>
Delivers one user prompt to the in-flight interactive session turn for
session_id, so the agent reads it before that turn ends.
Ok means the provider accepted the prompt into the running turn; the
caller then owns recording it in the transcript. Any error leaves the
prompt undelivered so callers can submit it as a later turn. Only
session-start and session-resume turns accept steering; utility and
review turns reject it. The default reports that the harness cannot
steer.
§Errors
Returns AgentError::Runtime when the harness cannot steer, no
interactive turn is running, or the provider rejects the prompt.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".