Skip to content

Policies And Approvals

github-actions[bot] edited this page Aug 12, 2026 · 1 revision

Policies And Approvals

->reading(callable $callback) lets you inspect, approve, or veto a request before it runs, based on the already-parsed, already-validated query rather than raw AI input:

->reading(function (Request $request, array $appliers) {
    return Decision::accept();
    return Decision::deny('Not allowed for this account.');
    return Decision::approve('Touches billing data and needs a human to confirm first.');
    return true;  // shorthand for Decision::accept()
    return false; // shorthand for Decision::deny()
});

Return Values

  • Decision::accept() or true: the request proceeds
  • Decision::deny($reason) or false: the tool immediately returns {"error": $reason} and the query never runs
  • Decision::approve($reason): the request only runs after a human approves it through Laravel AI's native Approvable and needsApproval() flow

If you already know Laravel AI's approval flow from elsewhere, there is nothing new to learn here. Decision::approve() is just this package's way of telling that same flow when to kick in.

Callback Contract

The callback must return a Decision or a bool. Returning null, or anything else, throws an InvalidArgumentException.

If you have no opinion on a request, return Decision::accept() or true explicitly rather than falling through.

$appliers are the fully validated, already-built Applier instances for this specific request, one per matched handler such as where, select, distinct, groupBy, orderBy, with, or withAggregate. That lets the callback decide based on what the query is actually about to do, not just what the raw request claimed.

Clone this wiki locally