pub struct AgentRun { /* private fields */ }Expand description
Runtime-owned single-consumer protocol for one agent run.
Self::next_message is the only output path. It yields durable runtime
events, explicit host-owned tool batches, and subscribed host-bridged hook
invocations from the same ordered channel.
Implementations§
Source§impl AgentRun
impl AgentRun
Sourcepub async fn submit_bridge_tool_outcomes(
&mut self,
batch_id: &ToolCallBatchId,
outcomes: Vec<(ToolCallId, ToolExecutionOutcome)>,
) -> Result<(), RuntimeError>
pub async fn submit_bridge_tool_outcomes( &mut self, batch_id: &ToolCallBatchId, outcomes: Vec<(ToolCallId, ToolExecutionOutcome)>, ) -> Result<(), RuntimeError>
Submits a complete batch of host-executed tool outcomes.
The host may prepare results concurrently, then submit the complete set in any order. The batch itself does not grant parallel-execution safety; the runtime validates the complete set and records it in pending-call order before starting the next model turn. Correctable validation errors keep the batch pending; a non-correctable recording error is converted into a failed tool result so the model loop can still recover.
Sourcepub async fn submit_hook_decision(
&mut self,
invocation_id: &HookInvocationId,
decision: HookDecision,
) -> Result<(), RuntimeError>
pub async fn submit_hook_decision( &mut self, invocation_id: &HookInvocationId, decision: HookDecision, ) -> Result<(), RuntimeError>
Submits a typed decision for the active host-bridged hook invocation.
Sourcepub async fn fail_hook_invocation(
&mut self,
invocation_id: &HookInvocationId,
message: String,
) -> Result<(), RuntimeError>
pub async fn fail_hook_invocation( &mut self, invocation_id: &HookInvocationId, message: String, ) -> Result<(), RuntimeError>
Reports a fail-closed host hook error for the active hook invocation.
Sourcepub async fn result(&mut self) -> Result<AgentLoopResult, AgentLoopError>
pub async fn result(&mut self) -> Result<AgentLoopResult, AgentLoopError>
Returns the collected loop result once the run has completed.
Unconsumed events are drained. An unresolved host-tool batch or hook invocation is reported as an error and cancellation is requested.
Sourcepub async fn cancel_and_wait(&mut self)
pub async fn cancel_and_wait(&mut self)
Cancels the loop producer and waits until its task has stopped.
This is the output-boundary cancellation path: once a consumer cannot accept another event, callers must stop provider/tool work before settling and persisting the runtime state.
Sourcepub async fn next_message(
&mut self,
) -> Result<Option<AgentRunMessage>, RuntimeError>
pub async fn next_message( &mut self, ) -> Result<Option<AgentRunMessage>, RuntimeError>
Returns the next runtime-owned run message.
SDK host adapters use this to execute bridge tool calls and subscribed
host hooks without exposing bridge handoff as a public RuntimeEvent.
Sourcepub async fn next(&mut self) -> Result<Option<AgentRunMessage>, RuntimeError>
pub async fn next(&mut self) -> Result<Option<AgentRunMessage>, RuntimeError>
Returns the next runtime-owned run message.
This Rust convenience alias has the same message-first semantics as
Self::next_message; it never filters host-tool handoffs.
Sourcepub fn request_cancel(&mut self)
pub fn request_cancel(&mut self)
Requests cancellation without waiting for the producer task to stop.
This is intended for synchronous cleanup guards that cannot await, such
as a facade tool-invocation lease being dropped before it is resolved.
Callers that own an async lifecycle should prefer Self::cancel_and_wait
so producer completion and the terminal result are observed explicitly.