# Laravel AI SDK Agent Audit: Approvals, Ownership Checks & Fake Tests (laravel/ai 1.x)

> Build or audit Laravel AI SDK 1.x agents and get a severity-ranked report, the fixed code and Agent::fake() Pest tests, so tools can't refund, delete or leak data unchecked.

Laravel AI SDK Agent Audit: Approvals, Ownership Checks & Fake Tests (laravel/ai 1.x) is a paid AI agent skill on Agensi by Hamza Alayed, in Security. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $1 (one-time purchase)
- Creator: [Hamza Alayed](https://www.agensi.io/creators/hamza-alayed)
- Category: [Security](https://www.agensi.io/skills/security)
- Version: 1.0
- Last updated: 2026-11-21
- Security: scan passed (2026-11-21); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/laravel-ai-sdk-agent-audit-approvals-ownership-checks-fake-tests-laravel-ai-1-x
- Tags: code-quality-review, security, agents-orchestration, apis-backend, testing-debugging, llm-ops

## About this skill

The Laravel AI SDK (`laravel/ai`, v1.0 on 23 Sep 2026, v1.1 with Agent Skills since) makes it a few lines of code to give a model tools that touch real data. Those same few lines can:

- let any signed-in user **continue someone else's conversation** (`continue()` does not check ownership; the docs say so),
- let the model **refund, delete or cancel with no human in the loop**,
- run an **unbounded tool loop** on your API bill,
- **leak one tenant's documents** through `SimilaritySearch`,
- or **break at runtime** (approval tools inside sub-agents, approval on a stateless agent, mixed prompt-cache TTLs).

This skill builds new agents the safe way and audits existing ones. Either way you get:

1. **`AI-AGENT-AUDIT.md`** — a SHIP / SHIP AFTER FIXES / BLOCK verdict, findings ranked CRITICAL→LOW with `file:line`, dismissed leads with reasons, and a list of changes.
2. **The fixed code** — pinned models, `#[MaxSteps]`, `Stop::unless` token budgets, user-scoped tools with `$request->validate()`, `Approvable` tools with `needsApproval()` rules, `conversationBelongsTo` ownership checks, tenant-scoped RAG.
3. **Pest tests that never call a provider** — `Agent::fake()->preventStrayPrompts()`, `AgentResponse::fakeWithPendingApprovals()`, a 403 test for foreign conversations.

Includes a read-only, standard-library **Python scanner** (16 rules, exit codes for CI) plus 8 manual checks a regex can't do (tool data scope, server-side limits, prompt injection via retrieved content, PII in prompts, rate limits).

Every API in the skill was checked against the official Laravel AI SDK documentation on 21 November 2026, and every code sample passes `php -l`.

## Requires

- Laravel 12 or 13 app
- laravel/ai 1.x
- PHP 8.3+
- Python 3.8+ (for the scanner)

## Known limitations

The scanner is regex-based: it finds leads, and the skill makes the agent confirm each one, but it can miss patterns written unusually (for example tools built in a factory class). It does not judge prompt quality, provider data-retention terms or model choice. Agent::fake() never runs your tools, so tool business logic needs its own unit tests (the skill shows how). Not an upgrade guide from laravel/ai 0.x to 1.0. Facts reflect the official docs as checked on 21 November 2026; later SDK releases may add or change APIs.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Laravel AI SDK Agent Audit: Approvals, Ownership Checks & Fake Tests (laravel/ai 1.x) skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What exactly does it check?

16 automated rules (ownership checks on continue(), destructive tools without approval, approval tools in sub-agents or on stateless agents, missing step/token budgets, unscoped similarity search, unvalidated tool arguments, hard-coded keys, prompt-cache mistakes, agents never faked in tests, and more) plus 8 manual checks such as tool data scoping, server-side limits and prompt injection through retrieved content.

### Does it call OpenAI or Anthropic?

No. The scanner is offline and read-only, and the tests it writes use Agent::fake() with preventStrayPrompts(), so CI fails instead of reaching a provider.

### How current is it?

Every API was checked against the official Laravel AI SDK documentation on 21 November 2026 (v1.x, including v1.1 features such as requireApproval() on MCP and filesystem tools). The skill tells the agent to grep vendor/laravel/ai if a method's existence is in doubt.

### How is this different from a general Laravel code review skill?

General reviewers don't know the AI SDK's specific traps: continue() does not check ownership, approvals in sub-agents silently don't surface, approval on a non-conversational agent throws, 1h instruction caching without 1h tool caching throws. This skill encodes those, fixes them with the SDK's own APIs and proves the fixes with tests.

### Can I use it for a brand-new agent?

Yes. Mode B walks through a spec, a tool-classification table (which tools need approval), Artisan scaffolding, a safety baseline and tests, then runs the scanner on the result.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
