pub struct StepContext<'a> {
pub inference: InferenceContext,
pub llm_response: Option<LLMResponse>,
pub gate: Option<ToolGate>,
pub messaging: MessagingContext,
pub flow: FlowControl,
pub pending_state_actions: Vec<AnyStateAction>,
pub pending_patches: Vec<TrackedPatch>,
/* private fields */
}Expand description
Step context — mutable state passed through all phases.
This is the primary interface for the runtime to maintain per-step state.
Unlike the old Extensions-based design, all phase-relevant data lives
in explicit typed fields, making every read and write site visible at the
type level.
The loop sets gate before each tool phase and llm_response after each
inference call. Plugins do not write to StepContext directly; they return
typed ActionSet values that the loop
applies via match.
Fields§
§inference: InferenceContextTools and prompt context for the current inference call. Persists across reset (tools are carried over).
llm_response: Option<LLMResponse>Set by the loop after each inference call. None before inference.
gate: Option<ToolGate>Set by the loop before BeforeToolExecute; None outside tool phases.
messaging: MessagingContextReminders and user messages produced during tool execution.
flow: FlowControlSet by plugins to request run termination.
pending_state_actions: Vec<AnyStateAction>State actions accumulated during a phase; reduced to patches by the loop.
pending_patches: Vec<TrackedPatch>Reduced patches ready for the thread store.
Implementations§
Source§impl<'a> StepContext<'a>
impl<'a> StepContext<'a>
Sourcepub fn new(
ctx: ToolCallContext<'a>,
thread_id: &'a str,
messages: &'a [Arc<Message>],
tools: Vec<ToolDescriptor>,
) -> Self
pub fn new( ctx: ToolCallContext<'a>, thread_id: &'a str, messages: &'a [Arc<Message>], tools: Vec<ToolDescriptor>, ) -> Self
Create a new step context.
pub fn ctx(&self) -> &ToolCallContext<'a>
pub fn thread_id(&self) -> &str
pub fn messages(&self) -> &[Arc<Message>]
Sourcepub fn initial_message_count(&self) -> usize
pub fn initial_message_count(&self) -> usize
Number of messages that existed before the current run started.
Sourcepub fn set_initial_message_count(&mut self, count: usize)
pub fn set_initial_message_count(&mut self, count: usize)
Set the initial message count (called by the loop after construction).
pub fn state_of<T: State>(&self) -> T::Ref<'_>
pub fn state<T: State>(&self, path: &str) -> T::Ref<'_>
pub fn run_policy(&self) -> &RunPolicy
pub fn run_identity(&self) -> &RunIdentity
pub fn snapshot(&self) -> Value
pub fn snapshot_of<T: State>(&self) -> TireaResult<T>
pub fn snapshot_at<T: State>(&self, path: &str) -> TireaResult<T>
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset step-specific state for a new step.
Preserves inference.tools across resets.
pub fn tool_name(&self) -> Option<&str>
pub fn tool_call_id(&self) -> Option<&str>
pub fn tool_idempotency_key(&self) -> Option<&str>
pub fn tool_args(&self) -> Option<&Value>
pub fn tool_result(&self) -> Option<&ToolResult>
pub fn tool_blocked(&self) -> bool
pub fn tool_pending(&self) -> bool
Sourcepub fn emit_patch(&mut self, patch: TrackedPatch)
pub fn emit_patch(&mut self, patch: TrackedPatch)
Push a reduced patch to the output queue.
Sourcepub fn emit_state_action(&mut self, action: AnyStateAction)
pub fn emit_state_action(&mut self, action: AnyStateAction)
Push a state action for deferred reduction.
Sourcepub fn emit_serialized_state_action(&mut self, action: SerializedStateAction)
pub fn emit_serialized_state_action(&mut self, action: SerializedStateAction)
Push a serialized action for intent-log persistence.
Sourcepub fn take_pending_serialized_state_actions(
&mut self,
) -> Vec<SerializedStateAction>
pub fn take_pending_serialized_state_actions( &mut self, ) -> Vec<SerializedStateAction>
Drain and return all accumulated serialized actions.
Sourcepub fn run_action(&self) -> RunAction
pub fn run_action(&self) -> RunAction
Effective run-level action for current step.
Sourcepub fn tool_action(&self) -> ToolCallAction
pub fn tool_action(&self) -> ToolCallAction
Current tool action derived from gate state.
Sourcepub fn result(&self) -> StepOutcome
pub fn result(&self) -> StepOutcome
Get the step outcome based on current state.