Netcraft

// How production AI apps are built

How do you run long AI jobs that don't fail halfway?

Split the job into durable steps whose results are saved, so a failed step is retried alone and the finished ones are kept. Mark errors a retry cannot fix as final. Run independent parts in parallel, within rate limits. Let optional steps fail without failing the job. Hold the user's credits until the end and return them once on failure.

Want it done for you? AI MVP Development: from €2,500, fixed quote in 24h →

Gabriel Cazaciuc

By , Founder & lead developer, Netcraft Digital

Last updated

Key facts

Sections generated at once per site
8; more hit the gateway's rate limit
Source: Netcraft Studio, our product, Nov 2026
Time to generate a site
A few minutes
Source: Netcraft Studio, our product, Oct 2026
Time to generate a custom worksheet
One or two minutes
Source: FișaEdu, our product, Oct 2026
A build counts as dead after
3 hours without progress; credits returned
Source: Netcraft Studio, our product, Nov 2026

Why do long AI jobs fail halfway?

Because a job that makes dozens of model calls over several minutes will hit at least one error. Models time out, providers return rate-limit errors, an image model returns nothing, a deploy restarts the server. A normal web request also has a time limit. If the whole job is one function, any of these throws away everything done so far, and the user waits for nothing.

Generating a site in Netcraft Studio takes a few minutes: a plan, the design, eight sections written in parallel, photos, a screenshot review and repairs. A custom FișaEdu worksheet takes one or two minutes and about a dozen kinds of step. Both run as durable workflows on Vercel Workflow. This guide is part of our production-ready AI app checklist.

What is a durable workflow?

A function whose steps save their results, so it can resume after a failure instead of starting over. Each step is retried on its own when it fails. When the workflow runs again, finished steps return their saved result without calling the model again. You do not pay twice for work that already succeeded.

async function draftStep(job) {
  "use step";
  return writeWorksheetDraft(job);
}

export async function customWorksheetWorkflow(job) {
  "use workflow";
  const check = await checkStep(job);
  if (!check.ok) throw new FatalError(check.message);
  const draft = await draftStep(job);
  const flagged = await reviewStep(job, draft);
  // fix, draw pictures, review pictures, save, notify
}

This is the shape of FișaEdu's worksheet workflow, shortened. The request is checked, the draft is written, the exercises are reviewed and the flagged ones are fixed. Then pictures are planned, drawn, looked at and redrawn if needed, and the sheet is saved. Each of those is a step.

Which errors should be retried, and which not?

Retry what can succeed next time, and stop at once on what cannot. A timeout or a rate-limit error usually passes on a retry. A request the checker rejected will be rejected again. FișaEdu throws a fatal error in that case, which tells the workflow not to retry. It does the same when the draft has the wrong number of exercises twice in a row. Netcraft Studio treats an empty AI gateway balance as final too.

Retries are set per step. On FișaEdu, the step that draws the worksheet's own illustration is retried once, and the “your worksheet is ready” email twice. Each step costs a model call, so the number reflects how much that step is worth.

How do you generate in parallel without breaking things?

Run independent parts at the same time, cap how many run at once, and order the parts that share data. Netcraft Studio runs each section of a site as its own workflow: HTML first, then up to six photos. Eight run at once, because more at the same time hit the gateway's rate limit.

Some blocks, like a header, appear on several pages. Studio writes them first, from the page that owns them, and only then lets the other pages place them. That way two pages built in parallel cannot overwrite each other's version. FișaEdu draws all the pictures of a worksheet in parallel, then reviews them in parallel, then redraws only the ones that failed.

What should happen when only part of the job fails?

Decide in advance which steps are essential and which are not. A finished result should never be thrown away because a nice-to-have step failed.

Step failsWhat happensWhy
Worksheet-ready emailThe worksheet stays finished; the error is loggedThe email only says where the sheet is
Worksheet illustrationThe sheet keeps a stock mascotThe sheet is already usable
Exercise pictureThe exercise is rewritten to be solvable from textA missing picture must not leave a broken question
Review of one Studio pageThe other pages are still reviewedPages are checked independently
A Studio photoA last pass retries photos still showing a placeholderPhotos can come later than text
Plan, draft or saveThe whole job fails and the user is refundedThere is no useful result without them

How do you refund a failed job exactly once?

Hold the credits when the job starts, settle the hold when it succeeds, and return it when it fails. Several paths can try to refund the same job: the workflow's error handler, a cancel by the user, and a sweep that finds stopped runs. On Netcraft Studio, a hold is taken out of its table before it is refunded, so only one of those paths gets it. If the refund itself fails, the hold goes back into the table, so a later path can try again.

Some runs die without reaching their error handler. Studio has a sweep for that. A build that has not changed for three hours, longer than any build is given, counts as dead. The sweep stops the run first, so it cannot finish a site its owner was already refunded for, and then returns the credits. On FișaEdu, the refund is tied to the update that marks the job failed. A job already marked refunded cannot be refunded again. How refunds fit into cost control is in controlling AI costs in production.

How do you run AI jobs at night?

As workflows started by a scheduled job, with a time budget. FișaEdu's nightly jobs write new worksheets for topics with no coverage yet and re-check published ones. They send their model calls through the gateway's batch API, which answers in minutes but sometimes takes an hour or more. The workflow sleeps and checks for results every minute. After five hours, it makes whatever is still missing with direct calls, so a night never runs into the next day's jobs. The checks these jobs run are described in how to stop an AI app from showing wrong content.

What does the user see while the job runs?

A progress status they can leave and come back to. Both products save the job's state in the database, so a page reload or a closed tab loses nothing. Studio shows the current stage of the build. FișaEdu emails a signed-in user when the worksheet is ready, so they do not have to wait on the page.

Durable AI jobs: what to check

  • Every model call is inside a step whose result is saved
  • Errors that cannot succeed on retry stop the job at once
  • Retries are set per step, by what the step is worth
  • Parallel work is capped below the provider's rate limit
  • Optional steps cannot fail a finished result
  • Credits are held during the job and refunded once on failure
  • A sweep finds runs that died silently and settles them
  • The job's state is saved, and the user can leave the page

If you want to see whether your AI job holds up on real data first, a 5-day AI prototype is the quickest test. To talk about your case, contact us.

// FAQ

Frequently asked questions

Another question? Write to us; you get an answer from the developer within one working day.

What is a durable workflow?

A function made of steps whose results are saved. A failed step is retried alone, and finished steps are not run again.

Do I need a workflow engine for a simple AI feature?

Not for one model call that answers in seconds. You need one when a job makes many calls, takes minutes, or must survive a deploy or a timeout.

Which workflow tool do you use?

Vercel Workflow, because our apps run on Vercel and Next.js. Other durable execution tools follow the same model of saved steps and retries.

What happens to the user's credits if generation fails?

In our products they are returned once, automatically. Netcraft Studio holds them during the build and returns them if it fails.

Why not generate everything in parallel?

Providers limit requests per minute. Above the limit, calls are refused and have to be retried. We cap Studio at eight sections at once.

// How production AI apps are built

Keep reading

// Start here

What does a production-ready AI app need?

A production-ready AI app needs ten things beyond working screens: accounts and roles, payments confirmed by Stripe webhooks, access rules on every table, automatic checks on AI output, cost limits per user and overall, background jobs that survive failures, error alerts, pages search engines can read, tested backups, and code, domain and data in the owner's name.

Read the guide

// How production AI apps are built

How do you control AI costs in a production app?

Give each task the cheapest model that does it well and keep the expensive one for hard cases. Cap paid calls per user, per day and globally. Put a bot check in front of costly actions. Tie usage to the plan the user pays for. Refund failed jobs once. Tag every call to see what each feature costs.

Read the guide

// How production AI apps are built

How do you stop an AI app from showing wrong content?

You never show a model's output unchecked. Force it into a strict schema, have a second model review it (ideally from another model family), re-solve questions with one right answer without the key, let a human approve anything published under their name, and re-check stored content on a schedule. Each layer catches errors the others miss.

Read the guide

// How production AI apps are built

How do you set up Stripe subscriptions and invoicing for an MVP?

Use Stripe Checkout for payment, and grant access only when your server receives a signed webhook. Record each event once, so retries cannot grant twice. Read the current subscription from Stripe instead of trusting event order. Keep a grace period for failed renewals. Run a scheduled job that issues exactly one invoice per payment in your accounting software.

Read the guide

AI MVP Development, at a fixed price

A production MVP with accounts, payments, admin and AI, live in about 2 weeks. From €2,500, 10–14 days. Written scope and price within 24 hours.