pub enum HookResult {
Continue,
Block {
reason: String,
},
Inject {
content: String,
},
Confirm {
message: String,
},
Modify {
input: Value,
},
Replace {
output: String,
},
}Expand description
What an extension handler returns after processing a hook event.
The runtime resolves multiple handlers by precedence:
Block,Confirm, andModifystop the handler chain forbefore_tool_call.Injectresults are accumulated forbefore_message.Continueis the no-op default — processing continues normally.
Variants§
Continue
Allow execution to proceed unchanged.
Block
Prevent the hooked operation. The reason is surfaced to the user.
Inject
Inject context — the extension provides text for the current request.
Placement depends on the hook (#297): on_session_start content is
appended to the system prompt (session-stable, cache-safe);
before_message content is attached to the newest user message on the
outgoing request as an ephemeral trailing block positioned AFTER the
conversational cache marker (per-turn, uncached tail, cache-neutral).
Confirm
Ask the runtime to get explicit user confirmation before proceeding. Only valid on before_tool_call hooks.
Modify
Replace the tool input before execution (structured JSON args).
Only valid on before_tool_call hooks. The output-side counterpart is
HookResult::Replace. The first modifier stops the handler chain.
Replace
Replace the tool output after execution (flat string), before it
enters history. Only valid on after_tool_call hooks. The input-side
counterpart is HookResult::Modify — distinct name because the payload
is an unstructured String, not structured Value. Enables native
output transforms (compression, redaction, summarization) by extensions.
The first transform stops the handler chain.
Trait Implementations§
Source§impl Clone for HookResult
impl Clone for HookResult
Source§fn clone(&self) -> HookResult
fn clone(&self) -> HookResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HookResult
impl Debug for HookResult
Source§impl Default for HookResult
impl Default for HookResult
Source§fn default() -> HookResult
fn default() -> HookResult
Source§impl<'de> Deserialize<'de> for HookResult
impl<'de> Deserialize<'de> for HookResult
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<HookResult, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<HookResult, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for HookResult
impl PartialEq for HookResult
Source§impl Serialize for HookResult
impl Serialize for HookResult
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for HookResult
Auto Trait Implementations§
impl Freeze for HookResult
impl RefUnwindSafe for HookResult
impl Send for HookResult
impl Sync for HookResult
impl Unpin for HookResult
impl UnsafeUnpin for HookResult
impl UnwindSafe for HookResult
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync 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> 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