pendingToolApproval property

  1. @override
ToolApprovalRequest? get pendingToolApproval
override

The unresolved approval request, if the last run stopped on one.

Implementation

@override
ToolApprovalRequest? get pendingToolApproval {
  final request = _pendingApprovalContent;
  if (request == null) return null;
  // The middleware types the call as [ai.ToolCallContent]; in practice a
  // function call carries the name and arguments, so match it dynamically
  // the same way the tool-approval middleware does.
  final dynamic toolCall = request.toolCall;
  return toolCall is ai.FunctionCallContent
      ? ToolApprovalRequest(
          toolName: toolCall.name,
          arguments: toolCall.arguments,
        )
      : ToolApprovalRequest(toolName: request.toolCall.callId);
}