#[non_exhaustive]pub struct BeforeToolsEvent<'a> { /* private fields */ }Expand description
The model asked for tools, before any of them runs (BeforeToolsEvent).
Implementations§
Source§impl<'a> BeforeToolsEvent<'a>
impl<'a> BeforeToolsEvent<'a>
Sourcepub fn agent(&self) -> &LocalAgent
pub fn agent(&self) -> &LocalAgent
The agent.
Sourcepub fn agent_mut(&mut self) -> &mut LocalAgent
pub fn agent_mut(&mut self) -> &mut LocalAgent
The agent, mutably: hooks may change its messages, system prompt, tools and state.
Sourcepub fn invocation_state(&self) -> &InvocationState
pub fn invocation_state(&self) -> &InvocationState
The caller’s per-invocation state.
Sourcepub fn invocation_context(&self) -> Option<&InvocationContext>
pub fn invocation_context(&self) -> Option<&InvocationContext>
The request this event belongs to.
Source§impl<'a> BeforeToolsEvent<'a>
impl<'a> BeforeToolsEvent<'a>
Sourcepub fn set_cancel(&mut self, cancel: impl Into<Cancel>)
pub fn set_cancel(&mut self, cancel: impl Into<Cancel>)
Cancels every tool call of the batch: true uses the default message, a string becomes the
error text of each tool result.
Sourcepub fn interrupt(
&mut self,
params: impl Into<InterruptParams>,
) -> Result<JsonValue, InterruptError>
pub fn interrupt( &mut self, params: impl Into<InterruptParams>, ) -> Result<JsonValue, InterruptError>
Raises an interrupt for human input (interrupt), with the id hook:beforeTools:<name>.
Returns the response when the agent resumed with one (or params carries a preemptive
response). Otherwise the interrupt is recorded on the event and the agent stops with it
once every callback has run; return the InterruptError with ? (it does not fail the
invocation) or simply return from the callback.
§Errors
The unanswered interrupt.
Trait Implementations§
Source§impl Debug for BeforeToolsEvent<'_>
impl Debug for BeforeToolsEvent<'_>
Source§impl From<&BeforeToolsEvent<'_>> for BeforeToolsEventData
impl From<&BeforeToolsEvent<'_>> for BeforeToolsEventData
Source§fn from(event: &BeforeToolsEvent<'_>) -> Self
fn from(event: &BeforeToolsEvent<'_>) -> Self
Source§impl From<&BeforeToolsEvent<'_>> for AgentStreamEvent
impl From<&BeforeToolsEvent<'_>> for AgentStreamEvent
Source§fn from(event: &BeforeToolsEvent<'_>) -> Self
fn from(event: &BeforeToolsEvent<'_>) -> Self
Source§impl HookEvent for BeforeToolsEvent<'static>
impl HookEvent for BeforeToolsEvent<'static>
Source§type Event<'a> = BeforeToolsEvent<'a>
type Event<'a> = BeforeToolsEvent<'a>
'a.impl<H> IntoHookImpl<BeforeToolsEvent<'static>> for Hwhere
H: for<'a> Hook<BeforeToolsEvent<'a>>,
impl<F, R> IntoSyncHook<BeforeToolsEvent<'static>> for F
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for BeforeToolsEvent<'a>
impl<'a> !UnwindSafe for BeforeToolsEvent<'a>
impl<'a> Freeze for BeforeToolsEvent<'a>
impl<'a> Send for BeforeToolsEvent<'a>
impl<'a> Sync for BeforeToolsEvent<'a>
impl<'a> Unpin for BeforeToolsEvent<'a>
impl<'a> UnsafeUnpin for BeforeToolsEvent<'a>
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> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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