// 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 →

By Gabriel Cazaciuc, 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 fails | What happens | Why |
|---|---|---|
| Worksheet-ready email | The worksheet stays finished; the error is logged | The email only says where the sheet is |
| Worksheet illustration | The sheet keeps a stock mascot | The sheet is already usable |
| Exercise picture | The exercise is rewritten to be solvable from text | A missing picture must not leave a broken question |
| Review of one Studio page | The other pages are still reviewed | Pages are checked independently |
| A Studio photo | A last pass retries photos still showing a placeholder | Photos can come later than text |
| Plan, draft or save | The whole job fails and the user is refunded | There 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.

