Background AI Tasks Need Queues, Not Longer API Calls

Illustrated infographic summarizing: Background AI Tasks Need Queues, Not Just Longer API Calls

By Greg Nowak. Updated 19 November 2026.

A customer report is taking too long, so someone increases the API timeout. That may get the demonstration working. Running the same process every month raises harder questions: can someone close their browser, who approves the report, and what happens when the client portal is unavailable?

Reliable background AI tasks need a persistent job record, a way to schedule work and a worker that can recover after interruption. For business owners and agency teams, the payoff is practical: people can see what happened and resolve problems without starting everything again.

Start with a job people can follow

Consider a workflow that generates a client report, waits for approval and uploads the approved version. Agree what “completed” means before choosing tools. Here, it means the approved report reached the portal and the system saved confirmation.

Create the business job before calling the model. Record the requester, client or workspace, input version, intended destination and approval requirement. As work progresses, add the provider response ID, saved output, attempt count, timestamps and destination record ID.

Show useful states: queued, running, awaiting_approval, applying, completed, failed and cancelled. An account manager should see “Waiting for approval” with an owner and next action.

Make scheduling recoverable too. A database worker can claim pending jobs directly. With a separate queue, save a dispatch record in the same database transaction as the job, then retry delivery until acknowledged. This closes the gap where a saved job never reaches a worker.

Choose the queue setup around the work

Start with the simplest approach your team can support. Volume matters, but so do approval waits, dependencies and the consequences of repeating an action.

Workflow Practical starting point Control to include
Internal draft, one processing step Database job table and worker Saved output, worker lease and recoverable status
Many incoming jobs or uneven demand Persistent jobs with a managed queue Concurrency limits, backoff and failed-job handling
Several dependent steps or lengthy approvals Consider a durable workflow engine Recorded progress, deadlines and recovery per step
Publishing, customer messages or financial actions Suitable foundation above, with explicit authorization Version-specific approval, duplicate protection and audit trail
Choose controls for the business consequence of failure, even when job volume is low.

A worker lease temporarily reserves a job; recovery must reclaim abandoned work without allowing overlapping writes. A durable workflow engine can reduce custom coordination code. Temporal documents recovery through persisted state and event history. External actions still need duplicate protection.

Use OpenAI background mode inside the workflow

OpenAI’s background mode runs Responses API requests asynchronously. The basic request remains straightforward; this example uses the model shown in the current documentation:

curl https://api.openai.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-6.2-astra",
    "input": "Prepare the monthly variance review.",
    "background": true
  }'

Save the returned response ID against the business job. Retrieve it with GET /v1/responses/{response_id}. Poll while the status is queued or in_progress, or use completion webhooks. Check the terminal status and validate the output before advancing the job.

The default completion window is soonest. Supported models also offer 2h and 8h windows for work that can wait. Choose around the actual business deadline.

Plan collection around OpenAI’s current data controls. The default background window uses roughly ten minutes of temporary storage. For Modified Abuse Monitoring projects, longer response retention in that window requires explicit store=true. Background processing can temporarily store data even with store=false or Zero Data Retention. Confirm the applicable window and project settings, then collect and save results promptly.

Make webhooks quick and retries safe

Follow OpenAI’s webhook guidance: verify signatures using the original request body and an official SDK helper, deduplicate with webhook-id, and durably record accepted events before returning 2xx. Let a worker handle further processing. Delivery retries can continue for up to 72 hours; that is separate from response retention. Add a scheduled check for stalled jobs.

Queue messages can repeat too. Amazon SQS standard queues use at-least-once delivery. Design each business action so repeating it does not create another upload, message or charge.

Give the intended action a stable key: one approved report version delivered to one client portal. Enforce uniqueness locally and pass that key to the destination API where supported. A timeout may occur after the destination accepted the update, so a local “done” flag is insufficient. Check the destination before retrying; send unresolved outcomes to a person.

Retry temporary failures with backoff, jitter and limits on attempts, elapsed time and spend. Invalid input or revoked access needs correction. Resume from the failed step so a portal outage does not trigger another paid generation.

Attach approval to the exact result

Save who approved which output version and destination. Editing the output should require fresh approval. Recheck permissions immediately before applying it.

Record cancellation internally and cancel the provider response where possible. Workers must check cancellation before consequential writes. Define how to handle an action already underway: an email already sent needs a different response from a draft awaiting review.

Agree who owns recovery after launch

Give operations a view of failed jobs, stalled work and overdue approvals. Each needs an owner and a safe next action. For agency handover, agree who receives alerts, investigates uncertain outcomes and authorizes retries.

Before release, demonstrate recovery from a worker restart, duplicate delivery, destination timeout and late cancellation. These are useful acceptance criteria for a delivery brief.

Greg can help turn one AI workflow into a practical plan covering job states, approvals, integrations and recovery ownership. Discuss your AI workflow with Greg to work out what a supportable first release needs.

Related on GrN.dk

Need help with this kind of work?

Discuss your AI workflow with Greg Get in touch with Greg.

Sources

Latest articles

Trace an intermittent NGINX 502 through Cloudflare, upstream attempts, and application logs so you can see where the request failed and who should pick it up.

Find the apps, scripts and printers that still send mail through Microsoft 365 with a mailbox password, then test a replacement before the December 2026 change.

Find subscriptions and insurance expenses in e-conomic that should be spread over several months. See how AI reads the supporting documents and how your finance lead approves the proposed allocations.

Before relying on an AI project briefing, check which files it covered. A practical workflow for tracking documents, recording gaps and verifying key claims.

Check whether your contact form rejects missing or invalid Turnstile tokens, handles failed checks for genuine users and delivers accepted enquiries to your team.

Compare Bing citations, identifiable AI visits and verified enquiries to see which pages deserve attention before you increase your AI search marketing budget.

Teamtailor is phasing out Riminder on 21 November 2026. Check your parser settings, contact fields and integrations, and make sure you have a process for deleting applicant data.

WordPress jobs running late? Learn how to separate scheduling problems, task errors and a growing backlog, then choose the right scheduler or runner.

Before changing an AI workflow, check that it still does the job. Use realistic examples, clear release criteria and a comparison with the version running today.

Sending an invoice does not mean it has arrived. Understand delivery statuses, the system requirements coming in 2027, and how focused AI support can help finance teams handle errors and follow-up.