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

    1

    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

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

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

    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

    #SeverityRuleLocationFindingStatus
    1CRITICALR01routes/web.php:9continue() with a conversation ID from the URL and no ownership checkFixed: conversationBelongsTo() → 403 + test
    2CRITICALM1app/Ai/Tools/LookupOrder.php:18Order::where('number', …) reads any customer's orderFixed: $this->user->orders()
    3HIGHR07app/Ai/Tools/RefundOrder.php:18Refund tool runs without approvalFixed: Approvable + needsApproval() above 20.00 + test
    4HIGHR02app/Ai/Agents/SupportAgent.php:24Approval tool CancelSubscription lives in sub-agent BillingAgent (approvals never reach the app)Fixed: tool moved to top-level agent
    5HIGHR03app/Ai/Agents/BillingAgent.php:19Approval tool on a non-conversational agentFixed: SupportAgent uses RemembersConversations
    6MEDIUMR04app/Ai/Agents/SupportAgent.php:15No #[MaxSteps] or token budgetFixed: MaxSteps(8) + Stop::unless(60k input tokens)
    7MEDIUMR10app/Ai/Agents/SupportAgent.php:30SimilaritySearch over all teams' articlesFixed: query: scoped to team_id
    8MEDIUMR06app/Ai/Tools/RefundOrder.php:18Model-supplied amount not validatedFixed: validate() + refundable_amount check
    9MEDIUMR09app/Ai/Agents/SupportAgent.php:15Agent never faked in testsFixed: 3 Pest tests
    10LOWR05app/Ai/Agents/SupportAgent.php:14#[UseCheapestModel] floatsFixed: #[Provider] + #[Model] pinned
    …3 more LOWFixed

    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:

    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.

    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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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 12
    or13 app
    laravel/ai 1.xPHP 8.3+Python 3.8+ (for the scanner)

    Permissions

    Terminal / Shell
    Read Files
    Write Files

    File Scopes

    app/
    routes/
    config/
    tests/
    resources/skills/
    AI-AGENT-AUDIT.md

    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.

    Listed13 days ago

    What's inside

    Frequently Asked Questions

    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.

    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.

    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.

    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.

    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.

    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.