pub type ToolConditionalFn = Arc<dyn Fn(String, Json) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send>> + Send + Sync>;Expand description
Decide whether a tool call is allowed to continue.
The callback receives the tool name and the current argument payload. It can
return Ok(None) to allow execution, Ok(Some(reason)) to reject the call
with a guardrail message, or an error to abort evaluation entirely.
This alias is Arc-backed so the runtime can clone conditional
guardrails into an evaluation snapshot and invoke them after registry locks
are released.
§Parameters
- First argument: Tool name being evaluated.
- Second argument: Current tool argument payload.
§Returns
A Result containing Ok(None) when execution is allowed or
Ok(Some(reason)) when the guardrail rejects the call.
§Errors
The callback can return any FlowError to abort
guardrail evaluation.
Aliased Type§
pub struct ToolConditionalFn { /* private fields */ }