pub struct HookContext { /* private fields */ }Expand description
Run-scoped context passed by shared reference to every AgentHook::on_event
call.
Carries the run’s identity and a shared Scratchpad. It is a driver
construct built once per run by AgentRunner;
nothing here reaches the sans-IO AgentRun
state machine. Hooks hold it by &, so all fields are read via accessors and
run-scoped mutation goes through scratchpad.
One HookContext is shared by every hook invocation in a run. At
tool_concurrency > 1 the
ToolCall / ToolResult
hooks for different tools in a turn can run concurrently against this shared
context — see the Scratchpad concurrency note for
how to store run-scoped state safely under that concurrency.
Implementations§
Source§impl HookContext
impl HookContext
Sourcepub fn is_streaming(&self) -> bool
pub fn is_streaming(&self) -> bool
Whether this run is driven by the streaming surface.
Sourcepub fn agent_name(&self) -> Option<&str>
pub fn agent_name(&self) -> Option<&str>
The agent’s configured name, if any.
Sourcepub fn scratchpad(&self) -> &Scratchpad
pub fn scratchpad(&self) -> &Scratchpad
The run-scoped shared scratchpad.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for HookContext
impl RefUnwindSafe for HookContext
impl Send for HookContext
impl Sync for HookContext
impl Unpin for HookContext
impl UnsafeUnpin for HookContext
impl UnwindSafe for HookContext
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
impl<T> DebuggableStorage for T
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> 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