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
impl TurnRunner
Sourcepub fn new(gateway: Arc<dyn ModelGateway>, executor: Arc<ToolExecutor>) -> Self
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).
Sourcepub fn with_hook(
gateway: Arc<dyn ModelGateway>,
executor: Arc<ToolExecutor>,
hook: Arc<dyn ToolUseHook>,
) -> Self
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).
Sourcepub async fn run(
&self,
context: TurnContext,
options: TurnRunOptions,
ctrl: RunControl,
) -> TurnOutcome
pub async fn run( &self, context: TurnContext, options: TurnRunOptions, ctrl: RunControl, ) -> TurnOutcome
Frames materialize from the active turn alone (Turn scope, policy-shaped).
Sourcepub async fn run_streaming(
&self,
context: TurnContext,
options: TurnRunOptions,
ctrl: RunControl,
) -> TurnOutcome
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.
Sourcepub async fn run_in_conversation(
&self,
state: ConversationState,
options: TurnRunOptions,
ctrl: RunControl,
) -> Result<ConversationOutcome, ConversationError>
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).
Sourcepub async fn run_in_conversation_streaming(
&self,
state: ConversationState,
options: TurnRunOptions,
ctrl: RunControl,
) -> Result<ConversationOutcome, ConversationError>
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.
Sourcepub async fn resume(
&self,
outcome: TurnOutcome,
request: ResumeRequest,
options: TurnRunOptions,
ctrl: RunControl,
) -> Result<TurnOutcome, ResumeRejection<TurnOutcome>>
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.