afterToolCall method

Future<ToolResult> afterToolCall(
  1. ToolCallContext ctx,
  2. ToolResult result
)

Runs afterToolCall on each enabled hook in REVERSE registration order (so the first-registered hook wraps the others). Each hook may modify the result.

Implementation

Future<ToolResult> afterToolCall(
  ToolCallContext ctx,
  ToolResult result,
) async {
  var current = result;
  for (final hook in _hooks.reversed) {
    if (!hook.enabled) continue;
    current = await hook.afterToolCall(ctx, current);
  }
  return current;
}