Skip to main content

Permission request

Default behavior (deny-all)

If permission_approve is set to "deny-all" (default) in config/copilot.php, all permission requests are automatically denied when you use Copilot::run() or Copilot::start(). This is a safe default when your main use case is text generation, where permissions are usually unnecessary.

Configurable values

If you allow user prompt input, "approve-safety" and "approve-all" are dangerous. Always use false or "deny-all". Even read-only access can be risky because it can expose your Laravel project code.

PermissionHandler::approveAll()

Use PermissionHandler::approveAll() to auto-approve all requests.

PermissionHandler::approveSafety()

Use PermissionHandler::approveSafety() to deny only high-risk permissions (shell, write) and auto-approve others.
This still may not be fully safe. If you need precise control, write a custom handler and decide based on $request['kind'].

PermissionHandler::denyAll()

Use PermissionHandler::denyAll() to deny everything.

Direct client usage

When you use CopilotClient directly, specifying onPermissionRequest is required, just like the official SDK.

Custom handler

To control approval or rejection per request type, pass a closure. $request and $invocation are arrays like the examples below.

$request

Other than kind and toolCallId, fields vary by kind.

$invocation

Response

Return an array for the permission decision. Using the PermissionRequestResultKind class is convenient.

Protocol details

In Protocol v3 (current default), permission requests are broadcast as session events (permission.requested) instead of JSON-RPC requests. The SDK handles this internally and responds through the session.permissions.handlePendingPermissionRequest RPC. How you use SessionConfig does not change. You only need to pass a handler to onPermissionRequest, and the SDK absorbs protocol differences.

PermissionRequestResultKind

You can return the ['kind' => 'approve-once'] format directly, but it is easier to read with PermissionRequestResultKind.

Available methods

If you prefer Laravel\Prompts\select over Laravel\Prompts\confirm, use PermissionRequestResultKind::select() for options.

no-result

If a handler cannot return a result (for example, in a non-interactive environment), you can return no-result. When no-result is returned, the RPC call is skipped and Copilot CLI applies its default deny behavior.
For the latest updates, see the GitHub repository.
Last modified on April 29, 2026