Skip to main content

HookEvent

Enum HookEvent 

Source
#[non_exhaustive]
pub enum HookEvent<'a> {
Show 20 variants TurnStart { turn_id: TurnId, }, OnSystemPromptBuilt { prompt: &'a str, }, BeforeProviderCall { messages: &'a [Message], }, AfterProviderCall { tokens_in: u32, tokens_out: u32, }, OnTextDelta { text: &'a str, }, OnToolCallProposed { call: &'a ToolCall, }, BeforeToolBatch { calls: &'a [ToolCall], }, BeforePermissionCheck { call: &'a ToolCall, }, AfterPermissionCheck { call: &'a ToolCall, decision: PermissionDecision, }, BeforeBashSandboxExec { command: &'a str, }, AfterBashSandboxExec { exit: i32, duration: Duration, }, BeforeToolCall { call: &'a ToolCall, }, AfterToolCall { call: &'a ToolCall, result: &'a ToolResult, }, OnToolResultObserved { observation: &'a ToolObservation, }, AfterToolBatch { results: &'a [ToolResult], }, OnDoomLoopDetected { signature: &'a str, }, OnBudgetExceeded { kind: BudgetKind, used: u64, limit: u64, }, OnProviderError { error: &'a ProviderError, }, OnTurnEnd { reason: TurnEndReason, }, TurnComplete { turn_id: TurnId, status: TurnStatus, },
}
Expand description

A lifecycle event emitted by the Talos runtime.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

TurnStart

The turn has started.

Fields

§turn_id: TurnId

Current turn identifier.

§

OnSystemPromptBuilt

The system prompt has been assembled.

Fields

§prompt: &'a str

Final prompt text.

§

BeforeProviderCall

Immediately before invoking the provider.

Fields

§messages: &'a [Message]

Messages sent to the provider.

§

AfterProviderCall

After the provider stream has completed.

Fields

§tokens_in: u32

Input tokens consumed.

§tokens_out: u32

Output tokens produced.

§

OnTextDelta

A text delta was observed.

Fields

§text: &'a str

Delta text.

§

OnToolCallProposed

A tool call was proposed by the model.

Fields

§call: &'a ToolCall

Proposed tool call.

§

BeforeToolBatch

Immediately before executing a batch of tool calls.

Fields

§calls: &'a [ToolCall]

Tool calls to execute.

§

BeforePermissionCheck

Immediately before evaluating permissions for a tool call.

Fields

§call: &'a ToolCall

Tool call being evaluated.

§

AfterPermissionCheck

Immediately after evaluating permissions for a tool call.

Fields

§call: &'a ToolCall

Tool call being evaluated.

§decision: PermissionDecision

Permission decision returned by the engine.

§

BeforeBashSandboxExec

Immediately before executing a bash command in the sandbox.

Fields

§command: &'a str

Bash command string.

§

AfterBashSandboxExec

Immediately after sandboxed bash execution completes.

Fields

§exit: i32

Process exit code.

§duration: Duration

Total execution duration.

§

BeforeToolCall

Immediately before invoking a tool.

Fields

§call: &'a ToolCall

Tool call being executed.

§

AfterToolCall

Immediately after invoking a tool.

Fields

§call: &'a ToolCall

Tool call that was executed.

§result: &'a ToolResult

Tool result returned by the tool.

§

OnToolResultObserved

A tool result was observed and added back into the conversation.

Fields

§observation: &'a ToolObservation

Owned observation payload.

§

AfterToolBatch

After a batch of tool calls has completed.

Fields

§results: &'a [ToolResult]

Tool results in input order.

§

OnDoomLoopDetected

Doom-loop detection fired.

Fields

§signature: &'a str

Doom-loop signature string.

§

OnBudgetExceeded

A runtime budget was exceeded.

Fields

§kind: BudgetKind

Budget category.

§used: u64

Amount used.

§limit: u64

Configured limit.

§

OnProviderError

A provider error occurred.

Fields

§error: &'a ProviderError

Provider error instance.

§

OnTurnEnd

The provider signaled turn end.

Fields

§reason: TurnEndReason

Turn-end reason.

§

TurnComplete

The turn completed.

Fields

§turn_id: TurnId

Current turn identifier.

§status: TurnStatus

Final turn status.

Implementations§

Source§

impl HookEvent<'_>

Source

pub fn kind(&self) -> HookEventKind

Returns the discriminant used for subscription and pre-filtering.

Source

pub fn is_permission_boundary(&self) -> bool

Returns whether this event is inside the permission read-only boundary.

Trait Implementations§

Source§

impl<'a> Debug for HookEvent<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for HookEvent<'a>

§

impl<'a> RefUnwindSafe for HookEvent<'a>

§

impl<'a> Send for HookEvent<'a>

§

impl<'a> Sync for HookEvent<'a>

§

impl<'a> Unpin for HookEvent<'a>

§

impl<'a> UnsafeUnpin for HookEvent<'a>

§

impl<'a> UnwindSafe for HookEvent<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more