Skip to main content

ActionHook

Type Alias ActionHook 

Source
pub type ActionHook = Arc<dyn Fn(String, Value) -> Pin<Box<dyn Future<Output = bool> + Send>> + Send + Sync>;
Expand description

Async hook called before each tool action. Return true to proceed, false to block.

When blocked, the loop inserts a synthetic observation {"ok": false, "error": "action blocked by reviewer", "kind": "blocked"} and continues to the next iteration without invoking the tool.

§Observer interaction

When a hook allows an action (true), the normal observer sequence fires:

  1. Observer::on_tool_call — called before the tool is dispatched
  2. Observer::on_step — called after the observation is recorded

When a hook blocks an action (false), the sequence is:

  1. Observer::on_action_blocked — called instead of on_tool_call
  2. Observer::on_step — called after the synthetic blocked observation is recorded

Use make_action_hook to construct a hook from a plain async fn without writing the Arc<dyn Fn…> boilerplate by hand.

Aliased Type§

pub struct ActionHook { /* private fields */ }