Skip to main content

TurnRunner

Struct TurnRunner 

Source
pub struct TurnRunner { /* private fields */ }
Expand description

The execution stack over the kernel’s ports: frame materialization, bounded model retry, tool batch dispatch through the hook and interaction seams, run control plumbing, and trace construction.

Implementations§

Source§

impl TurnRunner

Source

pub fn new(gateway: Arc<dyn ModelGateway>, executor: Arc<ToolExecutor>) -> Self

A runner with the default PassthroughHook — no tool-use filtering (the driver carries no opinion; opt in via TurnRunner::with_hook).

Source

pub fn with_hook( gateway: Arc<dyn ModelGateway>, executor: Arc<ToolExecutor>, hook: Arc<dyn ToolUseHook>, ) -> Self

A runner with a custom ToolUseHook applied between model output and tool dispatch (e.g. a FilterChain).

Source

pub async fn run( &self, context: TurnContext, options: TurnRunOptions, ctrl: RunControl, ) -> TurnOutcome

Frames materialize from the active turn alone (Turn scope, policy-shaped).

Source

pub async fn run_streaming( &self, context: TurnContext, options: TurnRunOptions, ctrl: RunControl, ) -> TurnOutcome

The streaming twin of TurnRunner::run. The model phase consumes provider deltas — each one forwarded to options.interaction.on_delta — instead of a single batch result; retry bookkeeping, tool dispatch, traces, and sealing are the same shared state machine. A retried attempt re-streams the same frame; deltas already observed are advisory history, and the host decides how to present the partial-then-reset flow.

Source

pub async fn run_in_conversation( &self, state: ConversationState, options: TurnRunOptions, ctrl: RunControl, ) -> Result<ConversationOutcome, ConversationError>

Frames materialize as the lossless merged view over committed history plus the active turn (Conversation scope — the options.frame policy is deliberately inert here). Consume/return: the state comes back with the active turn sealed and outcome-stamped; the host then calls commit (Completed) or abort_turn (Interrupted).

Source

pub async fn run_in_conversation_streaming( &self, state: ConversationState, options: TurnRunOptions, ctrl: RunControl, ) -> Result<ConversationOutcome, ConversationError>

The streaming twin of TurnRunner::run_in_conversation — same consume/return contract and entry gates, delta-driven model phase. options.frame stays deliberately inert here.

Source

pub async fn resume( &self, outcome: TurnOutcome, request: ResumeRequest, options: TurnRunOptions, ctrl: RunControl, ) -> Result<TurnOutcome, ResumeRejection<TurnOutcome>>

Continue a paused bare turn — the continuation half of TurnRunner::run/TurnRunner::run_streaming. Consumes the complete paused outcome plus the new ResumeRequest (decision + inject); the host no longer assembles reason/trace by hand. Validation runs before anything executes or any fact changes — a rejected request returns the untouched paused material in the ResumeRejection. Rounds, quota counts, prepared hook work, and queued inputs all come from the outcome’s Continuation: a trimmed or empty trace changes nothing, and lower limits stop the turn before external execution.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more