pub struct HookDecision { /* private fields */ }Expand description
A hook decision to continue, block, or replace input.
Returning Some(decision) stops the remaining hooks for that event, even when
the decision is continue_. Return None to let the next
hook decide. Default blocks execution with no reason or replacement.
Implementations§
Source§impl HookDecision
impl HookDecision
Sourcepub fn continue_() -> Self
pub fn continue_() -> Self
Continues the operation without modifications, skipping subsequent hooks.
Return None from the hook instead when later hooks should also run.
Sourcepub fn block(reason: impl Into<String>) -> Self
pub fn block(reason: impl Into<String>) -> Self
Blocks the prompt or tool call with the supplied reason.
A blocked prompt becomes an error; a blocked automatic tool call becomes an error result sent back to the model.
Sourcepub fn modify_input(input: Value, reason: impl Into<String>) -> Self
pub fn modify_input(input: Value, reason: impl Into<String>) -> Self
Continues with replacement tool input.
In a post-tool hook, the same field replaces the tool result instead.
Sourcepub fn modify_prompt(
prompt: impl Into<String>,
reason: impl Into<String>,
) -> Self
pub fn modify_prompt( prompt: impl Into<String>, reason: impl Into<String>, ) -> Self
Continues with replacement prompt text in a user-prompt-submit hook.
Sourcepub fn continue_execution(&self) -> bool
pub fn continue_execution(&self) -> bool
Returns whether execution should continue.
Sourcepub fn modified_input(&self) -> Option<&Value>
pub fn modified_input(&self) -> Option<&Value>
Returns the modified input, if any.
Sourcepub fn modified_prompt(&self) -> Option<&str>
pub fn modified_prompt(&self) -> Option<&str>
Returns the modified prompt, if any.