pub struct SessionHooks { /* private fields */ }Expand description
Shared handle captured by agent hook closures.
Lock order (never hold more than one at a time, never across .await):
runner(RwLock)system_prompt(RwLock)tools(RwLock)
The agent event pump and public AgentSession methods coordinate through
[super::AgentSessionInner]; SessionHooks only exposes runner/prompt/tool
snapshots for the pi-agent hook closures.
Implementations§
Source§impl SessionHooks
impl SessionHooks
Sourcepub fn new(runner: Arc<dyn ExtensionRunner>) -> Self
pub fn new(runner: Arc<dyn ExtensionRunner>) -> Self
Create hooks with the given extension runner.
Sourcepub fn set_runner(&self, runner: Arc<dyn ExtensionRunner>)
pub fn set_runner(&self, runner: Arc<dyn ExtensionRunner>)
Swap the extension runner (reload path).
Sourcepub fn runner(&self) -> Arc<dyn ExtensionRunner> ⓘ
pub fn runner(&self) -> Arc<dyn ExtensionRunner> ⓘ
Snapshot the current runner.
Sourcepub fn set_base_system_prompt(&self, prompt: String)
pub fn set_base_system_prompt(&self, prompt: String)
Replace the base system prompt.
Sourcepub fn set_system_prompt_override(&self, prompt: Option<String>)
pub fn set_system_prompt_override(&self, prompt: Option<String>)
Set or clear the per-turn system prompt override.
Sourcepub fn system_prompt_snapshot(&self) -> SystemPromptState
pub fn system_prompt_snapshot(&self) -> SystemPromptState
Snapshot system-prompt state.
Sourcepub fn effective_system_prompt(&self) -> String
pub fn effective_system_prompt(&self) -> String
Effective system prompt (override or base).
Sourcepub fn set_tools(&self, tools: Vec<Arc<dyn AgentTool>>)
pub fn set_tools(&self, tools: Vec<Arc<dyn AgentTool>>)
Replace the tools snapshot used by prepare_next_turn.
Sourcepub fn tools_snapshot(&self) -> Vec<Arc<dyn AgentTool>>
pub fn tools_snapshot(&self) -> Vec<Arc<dyn AgentTool>>
Clone the current tools snapshot.
Sourcepub fn before_tool_call_hook(self: &Arc<Self>) -> BeforeToolCall
pub fn before_tool_call_hook(self: &Arc<Self>) -> BeforeToolCall
Build the before_tool_call closure for AgentLoopConfig.
Sourcepub fn after_tool_call_hook(self: &Arc<Self>) -> AfterToolCall
pub fn after_tool_call_hook(self: &Arc<Self>) -> AfterToolCall
Build the after_tool_call closure for AgentLoopConfig.
Sourcepub fn prepare_next_turn_hook(self: &Arc<Self>) -> PrepareNextTurn
pub fn prepare_next_turn_hook(self: &Arc<Self>) -> PrepareNextTurn
Build the prepare_next_turn closure that refreshes system prompt + tools.
Trait Implementations§
Source§impl Clone for SessionHooks
impl Clone for SessionHooks
Source§fn clone(&self) -> SessionHooks
fn clone(&self) -> SessionHooks
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SessionHooks
impl RefUnwindSafe for SessionHooks
impl Send for SessionHooks
impl Sync for SessionHooks
impl Unpin for SessionHooks
impl UnsafeUnpin for SessionHooks
impl UnwindSafe for SessionHooks
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more