Works with the AI Agents you already use
Laravel AI SDK Agent Audit: Approvals, Ownership Checks & Fake Tests (laravel/ai 1.x)
by Hamza Alayed
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.
$1
Laravel AI SDK Agent Audit: Approvals, Ownership Checks & Fake Tests (laravel/ai 1.x)
Example session with this skill installed
Audit our Laravel 13 support bot built with laravel/ai before we ship it. It has LookupOrder and RefundOrder tools, a BillingAgent sub-agent that can cancel subscriptions, knowledge-base search, and a POST /support/{conversation} route.
- Read your context and instructions
- Compiled the laravel ai sdk
AI Agent Audit — support-bot — 2026-11-21
SDK: laravel/ai 1.1 · Laravel 13 · PHP 8.3
Scanner: exit 2 · 13 leads · 13 confirmed + 1 manual · 0 dismissed
Verdict
BLOCK — any signed-in user can continue any conversation, and the model can refund orders with no human approval.
Findings
| # | Severity | Rule | Location | Finding | Status |
|---|---|---|---|---|---|
| 1 | CRITICAL | R01 | routes/web.php:9 | continue() with a conversation ID from the URL and no ownership check | Fixed: conversationBelongsTo() → 403 + test |
| 2 | CRITICAL | M1 | app/Ai/Tools/LookupOrder.php:18 | Order::where('number', …) reads any customer's order | Fixed: $this->user->orders() |
| 3 | HIGH | R07 | app/Ai/Tools/RefundOrder.php:18 | Refund tool runs without approval | Fixed: Approvable + needsApproval() above 20.00 + test |
| 4 | HIGH | R02 | app/Ai/Agents/SupportAgent.php:24 | Approval tool CancelSubscription lives in sub-agent BillingAgent (approvals never reach the app) | Fixed: tool moved to top-level agent |
| 5 | HIGH | R03 | app/Ai/Agents/BillingAgent.php:19 | Approval tool on a non-conversational agent | Fixed: SupportAgent uses RemembersConversations |
| 6 | MEDIUM | R04 | app/Ai/Agents/SupportAgent.php:15 | No #[MaxSteps] or token budget | Fixed: MaxSteps(8) + Stop::unless(60k input tokens) |
| 7 | MEDIUM | R10 | app/Ai/Agents/SupportAgent.php:30 | SimilaritySearch over all teams' articles | Fixed: query: scoped to team_id |
| 8 | MEDIUM | R06 | app/Ai/Tools/RefundOrder.php:18 | Model-supplied amount not validated | Fixed: validate() + refundable_amount check |
| 9 | MEDIUM | R09 | app/Ai/Agents/SupportAgent.php:15 | Agent never faked in tests | Fixed: 3 Pest tests |
| 10 | LOW | R05 | app/Ai/Agents/SupportAgent.php:14 | #[UseCheapestModel] floats | Fixed: #[Provider] + #[Model] pinned |
| … | 3 more LOW | Fixed |
Tests added
- answers a normal question and sends the prompt to the agent
- returns pending approvals for a large refund instead of refunding
- forbids continuing someone else's conversation (asserts 403 and assertNeverPrompted)
Re-scan after fixes: exit 0 · 0 findings. php -l: all files pass.
Connects securely to your tools. The creator never sees your data.
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:
AI-AGENT-AUDIT.md— a SHIP / SHIP AFTER FIXES / BLOCK verdict, findings ranked CRITICAL→LOW withfile:line, dismissed leads with reasons, and a list of changes.- The fixed code — pinned models,
#[MaxSteps],Stop::unlesstoken budgets, user-scoped tools with$request->validate(),Approvabletools withneedsApproval()rules,conversationBelongsToownership checks, tenant-scoped RAG. - 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.
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
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 13 days ago
- Software
- Laravel 12or13 applaravel/ai 1.xPHP 8.3+
Python 3.8+ (for the scanner)
Permissions
File Scopes
The scanner is read-only and makes no network calls. The agent writes fixes and tests only in your project. No API keys are read; tests use Agent::fake() so no provider is called.
What's inside
Frequently Asked Questions
New in Security
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Security.