Skip to main content

make_action_hook

Function make_action_hook 

Source
pub fn make_action_hook<F, Fut>(f: F) -> ActionHook
where F: Fn(String, Value) -> Fut + Send + Sync + 'static, Fut: Future<Output = bool> + Send + 'static,
Expand description

Create an ActionHook from a plain async fn or closure.

This helper eliminates the need to manually write Arc::new(|name, args| Box::pin(async move { … })).

§Example

use llm_agent_runtime::agent::make_action_hook;

let hook = make_action_hook(|tool_name: String, _args| async move {
    // Block any tool called "dangerous"
    tool_name != "dangerous"
});