pub struct TurnEngine;Expand description
The single interpreter of Agentyk turn semantics.
Implementations§
Source§impl TurnEngine
impl TurnEngine
Sourcepub async fn start(
&self,
host: &TurnHost<'_>,
input: Message,
) -> PreparedTurnStart
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.
Sourcepub async fn finish(
&self,
host: &TurnHost<'_>,
turn_id: TurnId,
data: Value,
) -> Vec<EventData>
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.
Sourcepub async fn assemble(&self, host: &TurnHost<'_>) -> Result<AssembledTurn>
pub async fn assemble(&self, host: &TurnHost<'_>) -> Result<AssembledTurn>
Resolve the agent’s capabilities into the environment used by steps.
Sourcepub async fn prepare(
&self,
host: &TurnHost<'_>,
assembled: &AssembledTurn,
state: &mut TurnState,
) -> Result<PreparedStep>
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.
Sourcepub async fn guard(
&self,
host: &TurnHost<'_>,
state: &mut TurnState,
) -> Option<PreparedStep>
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.
Sourcepub fn complete_model(
&self,
state: &mut TurnState,
response: &ChatResponse,
) -> Vec<EventData>
pub fn complete_model( &self, state: &mut TurnState, response: &ChatResponse, ) -> Vec<EventData>
Apply a successful model operation and return its durable events.
Sourcepub fn fail_model(&self, state: &mut TurnState, error: &Error) -> Vec<EventData>
pub fn fail_model(&self, state: &mut TurnState, error: &Error) -> Vec<EventData>
Apply a failed model operation and return its durable event.
Sourcepub async fn complete_tool(
&self,
host: &TurnHost<'_>,
assembled: &AssembledTurn,
state: &mut TurnState,
call: &ToolCall,
output: ToolOutput,
denied: bool,
) -> Vec<EventData>
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.