Skip to content
mentoor

Topic 3 of 5 · 4 min read

Running long AI work in the background

Goal: Design a background job flow that covers start confirmation, status after the user leaves, a completion notice and cancellation.

When AI work takes minutes, turn it into a job: confirm it started, let the user leave, show its status when they return, tell them when it is done, and let them cancel. Do not hold the screen hostage. A person should never have to keep a tab open to protect a ten-minute task.

Check yourself · 1 of 3

A deep research task takes about 10 minutes. Where should the work run?

Choose one answer

Why it matters

Deep research modes, coding agents and batch jobs can run for minutes or hours. At that length, a spinner is not enough. The user will switch tabs, close a laptop or lose a connection. If the work is tied to the open page, any of those kills it, and the user pays for a result they never see. Tools such as ChatGPT deep research and Claude research modes show the pattern: you start the task, you are told it is running, and you come back to a result.

The five parts of a job flow

  1. Start confirmation. Say that the job began, what it will do, and roughly how long it usually takes. Add what it may cost, if it costs anything.
  2. Leave-safe. The job runs on the server, not in the page. Say so: "You can close this tab. We will keep working."
  3. Status on return. A page or list shows each job: queued, running, done, failed or cancelled, with the current step and when it started. The user should find it in one click.
  4. Completion notice. Tell the user when it is done through a channel they chose: an email, a push notification or an in-app badge. Name the job and link straight to the result. Notify on failure too.
  5. Cancel. A visible Cancel button that stops the work and says what is kept (partial results, files already changed) and what is not.

Before and after

Before: A research task runs inside the chat page. The user closes the laptop after 4 minutes. The task dies, with no message.

After: "Research started. About 8 minutes. You can leave: we will email you." Later, the Jobs list shows "Step 3 of 5: reading sources". The email links to the finished report.

What goes wrong

  • The job lives in the browser session and stops when the page closes.
  • No failure notice: the user waits for a result that will never come.
  • A cancel button that only hides the job while it keeps running and billing.
  • Messages every minute, until the user mutes them all.

Optional code branch (engineers). Return a job id at once, run the work in a queue, and let the client poll or subscribe for status. OpenAI's background mode follows this pattern.

Examples

A research job, step by step

  1. Start: "Research started. Usually 6 to 10 minutes. You can close this tab."
  2. Return: the Jobs list shows "Running, step 3 of 5, reading sources".
  3. Done: an email says "Your report on solar leasing is ready" with a link.
  4. Cancel: "Stop this job? We keep the 14 sources found so far."

A failure that is not silent

A batch job to tag 5,000 support tickets fails at ticket 3,120. The user gets a notice: "Tagging stopped at 3,120 of 5,000. The first 3,120 are saved. Resume or discard?" The user knows what is kept and what to do next.

Key points

  • A long AI task should be a server-side job, not something tied to an open page.
  • Confirm the start in plain words: what began, the usual duration and any cost.
  • The user needs a place to see the status of each job after they leave.
  • Notify on completion and on failure, and link straight to the result.
  • Cancel must really stop the work and say what happens to partial results.

Common mistakes

  • Running the job inside the page so closing the tab kills it.
  • Sending a completion notice but no failure notice.
  • A cancel button that hides the job but does not stop it.
  • Notifying too often, so people turn notifications off.

Check yourself · 2 of 3

Which message best confirms a long job has started?

Choose one answer

Check yourself · 3 of 3

A user cancels a half-finished batch job. What should the cancel message say?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic