Skip to main content

TurnEngine

Struct TurnEngine 

Source
pub struct TurnEngine;
Expand description

The single interpreter of Agentyk turn semantics.

Implementations§

Source§

impl TurnEngine

Source

pub async fn start( &self, host: &TurnHost<'_>, input: Message, ) -> PreparedTurnStart

Open a turn and apply user_prompt_submit hooks before its input is persisted.

Durable and immediate hosts both call this method, so prompt mutation and rejection cannot drift between execution strategies.

Source

pub async fn finish( &self, host: &TurnHost<'_>, turn_id: TurnId, data: Value, ) -> Vec<EventData>

Apply advisory turn_end hooks to a host-provided terminal summary.

data uses the public hook wire shape (success plus result/error details). The engine owns dispatch and error policy; a durable host owns when its terminal operation has been committed and therefore when to call this method. Like tool execution, a hook may run more than once if the durable host crashes before committing its effects.

Source

pub async fn assemble(&self, host: &TurnHost<'_>) -> Result<AssembledTurn>

Resolve the agent’s capabilities into the environment used by steps.

Source

pub async fn prepare( &self, host: &TurnHost<'_>, assembled: &AssembledTurn, state: &mut TurnState, ) -> Result<PreparedStep>

Prepare exactly one operation from the current state.

A durable host persists the returned events before scheduling the operation. The in-process host records them and executes immediately.

Source

pub async fn guard( &self, host: &TurnHost<'_>, state: &mut TurnState, ) -> Option<PreparedStep>

Apply cancellation and budget policy before one external action.

Hosts that execute a prepared tool batch one call at a time use this between calls so policy remains responsive inside the batch.

Source

pub fn complete_model( &self, state: &mut TurnState, response: &ChatResponse, ) -> Vec<EventData>

Apply a successful model operation and return its durable events.

Source

pub fn fail_model(&self, state: &mut TurnState, error: &Error) -> Vec<EventData>

Apply a failed model operation and return its durable event.

Source

pub async fn complete_tool( &self, host: &TurnHost<'_>, assembled: &AssembledTurn, state: &mut TurnState, call: &ToolCall, output: ToolOutput, denied: bool, ) -> Vec<EventData>

Apply one tool result, including post-tool middleware when the tool actually ran, and return its durable completion event.

Trait Implementations§

Source§

impl Clone for TurnEngine

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TurnEngine

Source§

impl Debug for TurnEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TurnEngine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.