pub struct PhaseContext {Show 18 fields
pub phase: Phase,
pub snapshot: Snapshot,
pub agent_spec: Arc<AgentSpec>,
pub run_identity: RunIdentity,
pub messages: Arc<[Arc<Message>]>,
pub tool_name: Option<String>,
pub tool_call_id: Option<String>,
pub tool_args: Option<Value>,
pub tool_result: Option<ToolResult>,
pub run_mode: RunMode,
pub adapter: AdapterKind,
pub tool_kind: ToolKind,
pub llm_response: Option<LLMResponse>,
pub resume_input: Option<ToolCallResume>,
pub suspension_id: Option<String>,
pub suspension_reason: Option<String>,
pub cancellation_token: Option<CancellationToken>,
pub profile_access: Option<Arc<ProfileAccess>>,
}Expand description
Execution context passed to phase hooks and action handlers.
Three input sources per ADR-0009:
agent_spec: immutable agent configuration (model, active_hook_filter, sections)snapshot: shared runtime state (StateKeys)run_identity: per-run identity (thread_id, run_id, etc.)
Fields§
§phase: Phase§snapshot: Snapshot§agent_spec: Arc<AgentSpec>Active agent spec (resolved from registry at each phase boundary).
run_identity: RunIdentityPer-run identity (thread_id, run_id, etc.). Immutable for the run.
messages: Arc<[Arc<Message>]>Messages accumulated in the current run.
tool_name: Option<String>§tool_call_id: Option<String>§tool_args: Option<Value>§tool_result: Option<ToolResult>§run_mode: RunMode§adapter: AdapterKind§tool_kind: ToolKind§llm_response: Option<LLMResponse>§resume_input: Option<ToolCallResume>§suspension_id: Option<String>§suspension_reason: Option<String>§cancellation_token: Option<CancellationToken>Optional cancellation token for cooperative cancellation at phase boundaries.
profile_access: Option<Arc<ProfileAccess>>Optional profile access for cross-run persistence.
Implementations§
Source§impl PhaseContext
impl PhaseContext
Sourcepub fn new(phase: Phase, snapshot: Snapshot) -> Self
pub fn new(phase: Phase, snapshot: Snapshot) -> Self
Create a minimal context (for testing or phases without extra data).
Sourcepub fn config<K: PluginConfigKey>(&self) -> Result<K::Config, StateError>
pub fn config<K: PluginConfigKey>(&self) -> Result<K::Config, StateError>
Read a typed plugin config from the active agent spec.
Returns Config::default() if the section is missing.
pub fn with_snapshot(self, snapshot: Snapshot) -> Self
pub fn with_agent_spec(self, spec: Arc<AgentSpec>) -> Self
pub fn with_run_identity(self, identity: RunIdentity) -> Self
pub fn with_messages(self, messages: Vec<Arc<Message>>) -> Self
pub fn with_tool_info( self, name: impl Into<String>, call_id: impl Into<String>, args: Option<Value>, ) -> Self
pub fn with_run_mode(self, mode: RunMode) -> Self
pub fn with_adapter(self, adapter: AdapterKind) -> Self
pub fn with_tool_kind(self, kind: ToolKind) -> Self
Sourcepub fn tool_policy_context(&self) -> Option<ToolPolicyContext>
pub fn tool_policy_context(&self) -> Option<ToolPolicyContext>
Build typed policy context for ToolGate/ToolPolicy hooks.
pub fn with_tool_result(self, result: ToolResult) -> Self
pub fn with_llm_response(self, response: LLMResponse) -> Self
pub fn with_resume_input(self, resume: ToolCallResume) -> Self
pub fn with_suspension( self, suspension_id: Option<String>, suspension_reason: Option<String>, ) -> Self
pub fn with_cancellation_token(self, token: CancellationToken) -> Self
Sourcepub fn profile(&self) -> Option<&ProfileAccess>
pub fn profile(&self) -> Option<&ProfileAccess>
Get profile access, if configured.
pub fn with_profile_access(self, access: Arc<ProfileAccess>) -> Self
Trait Implementations§
Source§impl Clone for PhaseContext
impl Clone for PhaseContext
Source§fn clone(&self) -> PhaseContext
fn clone(&self) -> PhaseContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PhaseContext
impl !RefUnwindSafe for PhaseContext
impl Send for PhaseContext
impl Sync for PhaseContext
impl Unpin for PhaseContext
impl UnsafeUnpin for PhaseContext
impl !UnwindSafe for PhaseContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more