pub trait AgentSession: Send {
// Required methods
fn capabilities(&self) -> &InterventionCapabilities;
fn events(&mut self) -> BoxStream<'static, ActivityEvent>;
fn intervene<'life0, 'async_trait>(
&'life0 self,
cmd: InterventionCommand,
) -> Pin<Box<dyn Future<Output = Result<(), HarnessError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn wait_result<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<Payload, HarnessError>> + Send + 'async_trait>>
where Self: 'async_trait;
}Expand description
A live agent run for one activity attempt.
Produced by AgentHarness::start. Exposes the negotiated capability set, a stream of
neutral events OUT, a neutral command sink IN, and a single terminal result.
Required Methods§
Sourcefn capabilities(&self) -> &InterventionCapabilities
fn capabilities(&self) -> &InterventionCapabilities
The capability set negotiated at start.
The server and ops console gate on THIS, never on harness identity. An empty set is a first-class advertisement — an observability-only harness supports no interventions.
Sourcefn events(&mut self) -> BoxStream<'static, ActivityEvent>
fn events(&mut self) -> BoxStream<'static, ActivityEvent>
The stream of neutral events produced by this run.
Every item is an ActivityEvent; how the adapter derives them (mapping a structured
notification, or demuxing interleaved stdout into mostly
aion_core::ActivityEventKind::Raw) is an adapter-internal detail invisible here.
Sourcefn intervene<'life0, 'async_trait>(
&'life0 self,
cmd: InterventionCommand,
) -> Pin<Box<dyn Future<Output = Result<(), HarnessError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn intervene<'life0, 'async_trait>(
&'life0 self,
cmd: InterventionCommand,
) -> Pin<Box<dyn Future<Output = Result<(), HarnessError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Delivers a neutral intervention command into the running agent.
A session whose advertised Self::capabilities set does not contain the command’s
primitive rejects it with HarnessError::CapabilityNotSupported. An observability-only
session (empty set) rejects every command this way; the server never routes one to it
because the advertised set is empty.
§Errors
Returns HarnessError::CapabilityNotSupported when the command’s primitive is not
advertised, HarnessError::StaleTarget when the command targets a superseded attempt,
or a transport/protocol error when delivery fails.
Sourcefn wait_result<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<Payload, HarnessError>> + Send + 'async_trait>>where
Self: 'async_trait,
fn wait_result<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<Payload, HarnessError>> + Send + 'async_trait>>where
Self: 'async_trait,
Awaits the single terminal result of the run.
Consumes the session: exactly one terminal result is produced per attempt, and it is the replay-authoritative activity output the worker captures.
The completed result is the canonical agent-outcome record. A completed run’s payload
is the JSON serialization of aion_core::AgentOutcome —
{"text": <the whole accumulated output>, "final_message": <the last completed answer>, "stop_reason": <canonical snake_case reason>, "session_id": <the handle of the conversation that produced the outcome>} —
from EVERY harness. The adapter maps its native terminal outcome onto the record at this
boundary (stop_reason spelled through the one
StopKind::canonical_stop_reason mapping);
a native outcome that cannot fill the record (e.g. a structured, non-text output) is a
typed HarnessError::Contract naming this contract and what was found — a deterministic
refusal the worker maps to a terminal activity failure — never a payload a workflow’s
decoder then chokes on.
§Errors
Returns HarnessError::Harness when the run reported an application-level failure,
HarnessError::Contract when the completed run’s native outcome cannot satisfy the
agent-outcome contract, or a transport/protocol error when the terminal result could not
be received.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".