pub enum HookEvent {
Show 14 variants
PreSendMessage,
PostSendMessage,
PreLlmRequest,
PostLlmResponse,
PreToolExecution,
PostToolExecution,
PostToolExecutionFailure,
Stop,
PreMicroCompact,
PostMicroCompact,
PreAutoCompact,
PostAutoCompact,
SessionStart,
SessionEnd,
}Expand description
Hook 事件类型
各事件的触发时机及可读/可写字段:
stop / skip 语义(统一规则):
stop:中止当前步骤及其所属子管线(不发送/不请求/不结束/不保存/中止 compact)skip:跳过当前步骤,同级步骤继续(仅 PreToolExecution:跳过该工具,其他工具继续)
| 事件 | 触发时机 | 可读字段 | 可写字段(HookResult 中返回即生效) |
|---|---|---|---|
PreSendMessage | 用户消息入队前 | user_input, messages | user_input(修改发送内容), action=stop, retry_feedback |
PostSendMessage | 用户消息入队后 | user_input, messages | 仅通知,返回值被忽略 |
PreLlmRequest | LLM API 请求前 | messages, system_prompt, model | messages, system_prompt, inject_messages, additional_context, action=stop, retry_feedback |
PostLlmResponse | LLM 回复完成后 | assistant_output, messages, model | assistant_output(修改最终回复), action=stop, retry_feedback, system_message |
PreToolExecution | 工具执行前 | tool_name, tool_arguments | tool_arguments(修改参数), action=skip |
PostToolExecution | 工具执行后 | tool_name, tool_result | tool_result(修改结果) |
PostToolExecutionFailure | 工具执行失败后 | tool_name, tool_error | tool_error(修改错误信息), additional_context |
Stop | LLM 即将结束回复 | user_input(回复文本), messages, system_prompt, model | retry_feedback(带反馈重试), additional_context, action=stop |
PreMicroCompact | micro_compact 前 | messages, model | action=stop |
PostMicroCompact | micro_compact 后 | messages | messages(修改压缩结果) |
PreAutoCompact | auto_compact 前 | messages, system_prompt, model | additional_context, action=stop |
PostAutoCompact | auto_compact 后 | messages | messages(修改压缩结果) |
SessionStart | 会话启动时 | messages | 仅通知,返回值被忽略 |
SessionEnd | 会话退出时 | messages | 仅通知,返回值被忽略 |
Variants§
PreSendMessage
PostSendMessage
PreLlmRequest
PostLlmResponse
PreToolExecution
PostToolExecution
PostToolExecutionFailure
Stop
PreMicroCompact
PostMicroCompact
PreAutoCompact
PostAutoCompact
SessionStart
SessionEnd
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for HookEvent
impl<'de> Deserialize<'de> for HookEvent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for HookEvent
impl Eq for HookEvent
impl StructuralPartialEq for HookEvent
Auto Trait Implementations§
impl Freeze for HookEvent
impl RefUnwindSafe for HookEvent
impl Send for HookEvent
impl Sync for HookEvent
impl Unpin for HookEvent
impl UnsafeUnpin for HookEvent
impl UnwindSafe for HookEvent
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.