pub trait Hook: Send + Sync {
// Provided methods
fn schema(&self) -> Vec<Tool> { ... }
fn system_prompt(&self) -> Option<String> { ... }
fn on_build_agent(&self, config: AgentConfig) -> AgentConfig { ... }
fn on_before_run(
&self,
_agent: &str,
_conversation_id: u64,
_history: &[HistoryEntry],
) -> Vec<HistoryEntry> { ... }
fn on_event(&self, _agent: &str, _conversation_id: u64, _event: &AgentEvent) { ... }
fn preprocess(&self, _agent: &str, _content: &str) -> Option<String> { ... }
fn scoped_tools(
&self,
_config: &AgentConfig,
) -> (Vec<String>, Option<String>) { ... }
fn dispatch<'a>(
&'a self,
_name: &'a str,
_call: ToolDispatch,
) -> Option<ToolFuture<'a>> { ... }
}Expand description
A pluggable subsystem that participates in the agent lifecycle.
All methods have default no-op implementations so subsystems only override what they need.
Provided Methods§
Sourcefn system_prompt(&self) -> Option<String>
fn system_prompt(&self) -> Option<String>
System prompt fragment appended to agent configs at build time.
Sourcefn on_build_agent(&self, config: AgentConfig) -> AgentConfig
fn on_build_agent(&self, config: AgentConfig) -> AgentConfig
Called by Runtime::add_agent() before building the Agent.
Sourcefn on_before_run(
&self,
_agent: &str,
_conversation_id: u64,
_history: &[HistoryEntry],
) -> Vec<HistoryEntry>
fn on_before_run( &self, _agent: &str, _conversation_id: u64, _history: &[HistoryEntry], ) -> Vec<HistoryEntry>
Inject context entries before each agent run.
Sourcefn on_event(&self, _agent: &str, _conversation_id: u64, _event: &AgentEvent)
fn on_event(&self, _agent: &str, _conversation_id: u64, _event: &AgentEvent)
Called by Runtime after each agent step during execution.
Sourcefn preprocess(&self, _agent: &str, _content: &str) -> Option<String>
fn preprocess(&self, _agent: &str, _content: &str) -> Option<String>
Preprocess user content before it becomes a message.
Return Some(modified) to transform, None to pass through.
Sourcefn scoped_tools(&self, _config: &AgentConfig) -> (Vec<String>, Option<String>)
fn scoped_tools(&self, _config: &AgentConfig) -> (Vec<String>, Option<String>)
Tools to include when building a scoped agent’s whitelist, plus an
optional scope prompt line (e.g. "skills: foo, bar").
Default: include all tools from schema() unconditionally, no
scope line. Override to gate inclusion on agent config fields.
Sourcefn dispatch<'a>(
&'a self,
_name: &'a str,
_call: ToolDispatch,
) -> Option<ToolFuture<'a>>
fn dispatch<'a>( &'a self, _name: &'a str, _call: ToolDispatch, ) -> Option<ToolFuture<'a>>
Dispatch a tool call by name. Return None if this hook doesn’t
own the tool — Env will try the next hook or the legacy entries.
Implementations on Foreign Types§
impl Hook for ()
No-op Hook for tests.