AI Features That Fail Safely: A Guide for Product Owners

AI Features That Fail Safely: A Guide for Product Owners cover image

Your new AI feature works beautifully in the demo. Then, in production, the provider times out on a Monday morning, a document comes back half-read, and a customer sees yesterday's "Approved" badge on a check that actually failed. AI features fail differently from the rest of your app: they're slower, they depend on an outside service, and they can return something that looks right but isn't.

This guide is for product owners and CTOs who have shipped, or are about to ship, AI features in a web application. It covers the ways AI features fail, the design rules that make those failures safe, and how to build them in Laravel.

How do AI features fail in production?

Plan for all of these, because each will happen eventually:

Failure What users see if you don't plan for it
Provider outage or rate limit A spinner that never ends, or a generic error page
Timeout on a long request The same, often after 30+ seconds
A tool the agent calls throws an error The whole AI action fails, even if the answer didn't need that tool
Malformed output Missing fields, wrong types, a number where text was expected
Confident but wrong output A plausible answer that is simply incorrect
Stale result shown as current Last week's result displayed as if it were today's
Cost spike Nothing at first, then a large invoice from the provider

The last two are the most dangerous, because nothing looks broken.

Rule 1: Never let an old result look like a new one

Laravel News' Decide with Jev series (23 November 2026) shows this exact bug: a previous check's "passed" label stays on screen when a later request fails, so the new check appears to have passed too.

The fix is a design rule, not a library:

  • Every AI run is a new record with its own status, starting as "pending" or "needs review".
  • Only a completed, validated result can move it to a final state.
  • A failure is saved as a failure, and the screen says so.
  • The old result is never reused for a new request without a clear "from 3 days ago" label.

In practice that's a small table:

Schema::create('ai_runs', function (Blueprint $table) {
    $table->id();
    $table->morphs('subject');           // the ticket, invoice, document...
    $table->string('feature');           // 'ticket-summary', 'invoice-extract'
    $table->string('status');            // pending, succeeded, failed, needs_review
    $table->json('result')->nullable();
    $table->text('error')->nullable();
    $table->timestamps();
});

Your interface then shows the status of the latest run, and nothing else. It's simple, and it removes the most misleading failure there is.

Rule 2: Run AI work in the background, with retries and a deadline

AI requests are slow and sometimes fail for a moment. Don't make a web request wait for them. Put them on a queue, retry with growing delays, and stop retrying after a deadline that makes sense for the feature.

Laravel 13.43 added a #[RetryFor] attribute that sets that deadline on a job (Laravel News):

use Illuminate\Queue\Attributes\RetryFor;

#[RetryFor(hours: 4)]
class SummarizeTicket implements ShouldQueue
{
    use Queueable;

    public function __construct(public AiRun $run) {}

    public function backoff(): array
    {
        return [10, 60, 300]; // seconds between attempts
    }

    public function handle(): void
    {
        // call the agent, validate the result, then:
        $this->run->update(['status' => 'succeeded', 'result' => $result]);
    }

    public function failed(Throwable $e): void
    {
        $this->run->update(['status' => 'failed', 'error' => $e->getMessage()]);
    }
}

The failed() method is the important part: when retries run out, the run is marked failed and the user sees it, instead of a "pending" that lasts forever.

Rule 3: Have a second provider, and know when it kicks in

Laravel's AI SDK can take a list of providers, for example provider: [Lab::OpenAI, Lab::Anthropic], and fail over to the next one on rate limits, overloads or exhausted credits. Ordinary errors don't trigger failover, so you still need the retry and failure handling above.

Two things to check before relying on failover:

  • Test the second provider with your real prompts. Different models give different results, especially for structured output.
  • Check your data agreements cover both providers, because failover sends the same data to a second company. If that data includes personal data, see our guide to sending customer data to AI safely.

Rule 4: Let agents recover from tool failures

Agents call tools: look up an order, search help articles, check stock. Before Laravel AI SDK 1.4 (13 November 2026), a tool that threw an exception ended the whole run. Now the SDK sends the error back to the model as a failed tool result, so it can explain the problem or try another tool, and a ToolFailed event lets you log or report it.

That's usually what you want for a support assistant. For a tool where failure must stop everything (a payment, for example), the release notes show how to restore the old behaviour by rethrowing from a listener:

Event::listen(ToolFailed::class, fn (ToolFailed $event) => throw $event->exception);

Decide per feature which behaviour is right, and write it down.

Rule 5: Validate AI output like user input

Treat what the model returns as untrusted input. Structured output (a schema of expected fields) helps a lot, but still check:

  • Required fields are present and have the right type.
  • Values are plausible: a total isn't negative, a date isn't in 1970, a category is one you actually have.
  • Cross-checks pass: line items add up to the total, the customer ID exists and belongs to this account.

Laravel's validator works for this, and Laravel 13.43 can turn a JSON schema into validation rules (JsonSchema::rules()), so the schema you give the model can also check what comes back. Output that fails validation goes to "needs review", not into your database as final.

Rule 6: Put a person between AI and anything that matters

For confident-but-wrong answers, no technical rule replaces review. Match the level of review to the impact:

Impact Example Review
Low Summaries for internal staff, search ranking None needed; show it's AI-generated
Medium Data extracted from documents, ticket routing Spot checks plus a low-confidence queue
High Customer emails, refunds, prices, anything legal A person approves every action

Our guide to AI agent guardrails covers approvals and limits for agents that take actions.

Rule 7: Design the failure screen

Every AI feature needs three designed states, not one:

  • Working: "Summarizing… you can leave this page, we'll update it when it's ready."
  • Failed: what happened in plain words, and what to do: retry, do it manually, or wait.
  • Needs review: the result with the uncertain parts highlighted.

And a manual path: the user must always be able to do the task without AI. If the AI feature is down for a day, your business should be slower, not stopped.

Rule 8: Measure, and test the failures on purpose

  • Log every run: feature, provider, duration, token usage, status. Alert when failure rate or cost jumps.
  • Keep a test set of real inputs with expected outputs, and run it whenever you change the prompt, model or provider.
  • Test failure paths automatically. The AI SDK's fakes let tests simulate errors and check that the run is marked failed and the screen says so, without calling a real provider.

A checklist for every AI feature

  1. Each run has its own status; old results are never shown as new.
  2. Work runs on a queue with retries, backoff and a deadline.
  3. failed() marks the run as failed and tells the user.
  4. A second provider is configured and tested, with data agreements in place.
  5. Tool failure behaviour is decided per feature.
  6. Output is validated before it's saved as final.
  7. Review matches the impact of the action.
  8. Working, failed and needs-review screens are designed, with a manual path.
  9. Runs, costs and failure rates are logged and alerted on.
  10. Failure paths have automated tests.

If you're still choosing which AI features to build, start with six practical AI features for an existing Laravel app.

Build AI features your team can trust

CodeBrisk is a Laravel web and mobile app development company, founded in 2014, with Laravel experience since 2015 and a Top Rated, 100% Job Success record on Upwork. We add AI features and automations to existing Laravel apps, with the failure states, reviews and monitoring that make them safe to rely on.

See our AI integration and automation service, or contact us to talk about the feature you have in mind.

Written by

Rizwan Aslam

Founder and CEO of CodeBrisk, with years of experience building web applications with Laravel and leading a team of expert developers.

More about Rizwan
Launch
project
Book a call with CodeBrisk