BeforeToolCallHook typedef

BeforeToolCallHook = FutureOr<BeforeToolCallResult?> Function(BeforeToolCallContext context, CancelToken? cancelToken)

Called before a tool is executed (pi's beforeToolCall).

The hook receives the run's CancelToken and is responsible for honoring it. A throw is converted into an error tool result (pi semantics).

Implementation

typedef BeforeToolCallHook =
    FutureOr<BeforeToolCallResult?> Function(
      BeforeToolCallContext context,
      CancelToken? cancelToken,
    );