For work that may outlast an HTTP request, accept the request, persist a caller-owned job, and let a worker finish it after the connection closes. Return 202 Accepted with a status location or job ID; the client then checks authorized status and retrieves the result. Acceptance means the server took responsibility for processing—not that processing has finished.
When a durable job is the right fit
Use this pattern when an operation may exceed the request’s practical time budget and the client can return later for status or a completed artifact. It decouples user-facing request handling from provider or background-work duration. It is an architectural option, not a requirement for every workload.
A synchronous request/reply is simpler when work reliably finishes within the request budget and an immediate result is part of the contract. A CLI watched in a terminal or an unattended overnight batch may not have a user-facing held-connection problem to solve. Choose asynchronous jobs because the interaction calls for them, not simply because a task uses a model or other provider.
How the request lifecycle works
- Submit authenticated work. The client sends the request with a stable idempotency key. The API authenticates the caller and validates both the payload and intended action before accepting work. Microsoft Learn’s Azure Architecture Center states, “The API should validate the request and the action to be performed before it starts the long-running process,” in its Asynchronous Request-Reply pattern.
- Deduplicate the request. Look up a job by caller identity and idempotency key. If one already exists, return that job’s current identifier and state rather than scheduling a duplicate. Scope the key to the real caller: a shared service account used as the only scope can merge otherwise distinct end-user requests.
- Persist ownership and arrange delivery. Create a durable job record associated with the caller, then hand it to a worker, commonly through a queue. The record supports status and result ownership; the queue or equivalent handoff decouples execution. These are distinct responsibilities.
- Acknowledge acceptance. Return
202 Acceptedwith a job identifier or aLocationpointing to a status resource. ARetry-Afterhint can suggest when the client should poll again. The response is an acknowledgement, not a completion result. - Run the work outside the request. A worker safely claims the job, calls the provider, and records a terminal success or failure with structured details suitable for clients and operators.
- Let the client follow up. The client polls the authorized status resource or receives a push notification where supported. On success, it retrieves the artifact. Define how long job and result data remain available and how they are cleaned up.
What belongs in the job resource
A job row should let the service answer three questions: who owns this work, where is it in its lifecycle, and what can the client retrieve or understand about its outcome? One proposed FastAPI implementation uses a report_jobs table with owner, idempotency key, prompt, result and error fields, timestamps, and a token estimate. Its sample status values are queued, running, succeeded, and failed; these are example choices, not mandatory standard values. The sample enforces UNIQUE (user_id, idempotency_key). See the original proposal, “Deliver Completions With a Job Row, Not a Held Connection”.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minute#1 Best Overall
Persist only what the workflow needs. A stored prompt may contain sensitive information, so the job store requires access controls and an explicit retention decision. Each status and result read must authorize the caller against the job’s owner. The proposal returns 404 for a missing job and for a job owned by someone else, avoiding disclosure that another user’s record exists.
Retries and failure-safe handoff
Idempotency prevents a common failure mode: a client loses the response after the server accepted work, retries, and accidentally creates a second job. A caller-scoped unique key lets the retry recover the existing job. It does not, by itself, make every step of execution exactly-once.
Rank #2
The record and queue publication may be separate operations. A failure between them can leave a persisted job that was never delivered, or delivery may be retried. The proposal also separates budget reservation from job insertion and broker publication. Where the storage system supports it, a transactional outbox can tie durable state changes to eventual delivery. Whatever mechanism is chosen, worker claims, state transitions, and provider side effects should tolerate duplicate delivery and retries.
The example checks for an existing job before reserving budget, supporting deduplication for a repeated caller/key. Its worker attempts a queued-to-running claim so duplicate queue deliveries do not run the same job concurrently. Its budget is estimated from the prompt before the provider responds, and the shown completion path does not reconcile that estimate with actual provider usage. Treat this as an implementation caveat to address in a real system, not evidence that every deployment will miscount or duplicate work.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallRank #3
- Simple shift planning via an easy drag & drop interface
- Add time-off, sick leave, break entries and holidays
- Email schedules directly to your employees
Choose the interaction, not just the transport
| Approach | Useful when | Costs or limits |
|---|---|---|
| Synchronous request/reply | Work reliably finishes inside the request budget and an immediate result is part of the contract. | Processing duration remains coupled to the client connection and request lifecycle. |
| Durable job plus polling | Work is long-running, clients can make follow-up requests, and a status resource is useful. | Requires persisted state, retention and cleanup, polling behavior, and worker operations. |
| Durable job plus push notification | Clients need timely completion notices and callback or push infrastructure is available. | Adds notification delivery, authorization, and retry concerns. |
| Streaming response | The user needs incremental output as it is generated. | It is a different contract from accepting work and later retrieving a completed artifact. |
| Queue or reply queue | Back-end work and callers need decoupling, or clients aggregate multiple results. | Adds broker operations and asynchronous result correlation. |
Periodic polling is useful when callbacks are unavailable or long-lived connections are undesirable. Long polling can reduce the wait between checks, but it still holds a connection until data arrives or a timeout occurs, so it does not solve the held-connection concern in the same way. For other notification needs, Microsoft’s guidance discusses server-sent events (SSE), WebSockets or SignalR, webhooks, and reply queues. Those choices change delivery mechanics; they do not eliminate the need to define ownership and result access.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Operational decisions to make before launch
- Lifecycle: define allowed states and transitions, including what happens if a worker stops after claiming a job.
- Errors: record structured, useful failure details without exposing secrets or sensitive provider data to the wrong audience.
- Cancellation: decide whether clients can cancel queued or running work and what cancellation means once a provider call has begun.
- Polling: document the status resource and a sensible polling interval; use
Retry-Afterwhere appropriate. - Retention: set expiration and cleanup behavior for job records, prompts, errors, and result artifacts.
- Authorization: enforce ownership checks on every status and artifact read, not only when the job is created.
- Reliability: plan for duplicate submissions, worker interruption, provider failure, and consistency across persistence and delivery.
A proposed implementation is not a production guarantee. The cited FastAPI example is presented as a working slice, not a benchmark or reported test result. Its suggested checks include duplicate submissions, worker interruption, provider failure, and cross-user result access; no execution results are reported. A broker, worker, and persistent store also add operational complexity, so account for those costs alongside the benefit of decoupling.
Quick Recap
Best Value
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

