Use Durable RunsBeta
Use a durable run for long-running requests when you don't want to keep a connection open until the run finishes. A durable run keeps working even if you close the browser or lose your connection. For how durable runs behave when a pod stops or you redeploy, see Durable Runs.
Prerequisites
- You must have a service with a published pipeline. For details, see Publish a Pipeline to a Service.
- The service must run on your organization's Fleet pool.
- The pipeline must run on Haystack 3.1.1 or later. If the pipeline pins a Haystack version, the pin must be an exact version. A pipeline without a pin runs on the default version, which qualifies.
- The cluster that hosts your organization must have a durable store. Without one, no service offers durable runs.
- Durable runs aren't paused on the service. A service accepts durable runs unless you pause them.
- You have the permissions in Durable Runs. To use durable runs in Haystack Enterprise Platform, you also need the
search-history: readpermission.
To check a service from your own tooling, read it with a GET request. durable_available is true when the service accepts durable runs now. If the service can't take them, durable_support_reason says why.
Submit a Durable Run
Durable runs support Agents, asynchronous pipelines, and Agents nested in tools or SuperComponents.
- In Haystack Enterprise Platform, click Gateway in the navigation and open the service.
- Click Connect.
- Next to a chat endpoint, select Durable. It's selected by default unless durable runs are paused. The search endpoints don't offer it. If the service can't take durable runs, a notice under the endpoint says why.
- Click Test this service.
- Edit the request body if needed, and click Start run. The run's details open under Runs, where you follow it.
A durable request can't include files, a search_session_id, or debug.
Submit from Your Own Tooling
- On Connect, copy the Submit with cURL example.
- Set
HAYSTACK_API_KEYto an API key with access to the service. - Set
DURABLE_IDEMPOTENCY_KEYto a value of 1 to 512 bytes that you haven't used for another run. - Send the request.
A new run answers with 202 and a Location header that points to the run. To retry a request, send it again with the same key and the identical JSON body, within 15 minutes of the first submission. The service then returns the original run with an Idempotent-Replay: true header, and with 200 if the run already finished. A key belongs to the user or API key that sent it.
To keep files between runs, set session_id in the request body to a stable ID of 1 to 128 letters, digits, _, or -. Runs in the same workspace with the same ID restore and save the same files, whichever service they run on. The pipeline needs session storage. For details, see Enable Session Storage.
Troubleshoot Refused Submissions
A refused submission answers with an HTTP status and an error code. Only 429 durable_capacity_exhausted, 409 submission_window_expired, and 422 invalid_submission refusals add a run to Completed runs. A 409 ambiguous_submission adds one to Active. Find the code in the table.
| Error | What to Do |
|---|---|
403 forbidden | Shared, prototype, and external access tokens can't use durable runs. Use an API key or sign in. |
| 404 | The service doesn't exist in this workspace. Check the workspace name and the service ID. |
409 deployment_not_runnable | The service has no active revision. Deploy it first. |
409 service_undeployed | The service is deactivated. Activate it first. |
409 active_revision_changed | The service was redeployed while you submitted. Submit again. |
409 durable_not_enabled | Durable runs are paused on the service. See Pause Durable Runs on a Service. |
409 idempotency_conflict | You reused an Idempotency-Key with a different request body. Use a new key, or send the original body. |
409 submission_window_expired | The service didn't accept the run within 15 minutes of its first submission. Submit it again with a new Idempotency-Key. |
409 ambiguous_submission or engine_conflict | The platform can't tell whether the run started. Look for the run under Runs. Sending the identical request again returns the same error, so change the request or the key to start a new run. |
409 execution_expired | The run for this key no longer exists, usually because it finished more than 7 days ago. Submit again with a new key. |
422 durable_fleet_required | The service doesn't run on your organization's Fleet pool. |
422 durable_store_missing | The cluster has no durable store. Ask your administrator to set one up. |
422 unsupported_haystack_version | The pipeline pins a Haystack version older than 3.1.1, or a value that isn't an exact version. Pin an exact version, 3.1.1 or later. |
422 unsupported_graph | The service's pipeline configuration isn't valid YAML or has no components. Fix the pipeline and publish it again. |
422 unsupported_submission | Remove files, search_session_id, and debug from the request. |
422 invalid_inputs | A params entry doesn't fit the pipeline's inputs, for example because it isn't an object. Fix params. |
422 payload_too_large | The request and the pipeline configuration together are larger than 1 MB. Make the inputs smaller. |
422 invalid_submission | The durable store refused the run, for example because the request and the service's credentials together are larger than 1 MB. Make the inputs smaller. |
422 invalid_idempotency_key | Set an Idempotency-Key header of 1 to 512 bytes. |
429 durable_capacity_exhausted | The durable store reached its cap on unfinished runs. Wait for runs to finish or cancel some. Then retry with the same key after the Retry-After time, within 15 minutes of the first submission. |
503 durable_unavailable | The durable store can't be reached, or the service was busy with other submissions for more than 3 seconds. Retry after the Retry-After time with the same key. |
View Durable Runs
- Open the service and click Runs.
- Find your run in Active or in Completed runs. Active lists runs that are submitting, queued, running, or waiting. Completed runs lists finished runs and some refused submissions.
- To see more runs, click Load older at the bottom of a list. To reload a list, click Refresh.
- To open a run's details, click its query. To go back to the lists, click All runs.
A run can carry one of these labels when the platform can't confirm its state:
- Stale: The platform hasn't read the run's state for more than a minute. The label goes away after the next successful read.
- Missing: The durable store no longer has the run, so its result is gone. A finished run shows Missing once its result is older than 7 days. Submit a new run if you still need the result.
- Submission outcome unknown: The platform can't tell whether the run started. Submit a new run with a different request or key.
On a run's details, the output shows the text the pipeline streams. For an Agent, it also shows each tool call in the order the calls happen. When the run finishes, the final result replaces the streamed text.
A failed run's error shows at most 512 characters, and URLs in it show as [redacted URL]. If the error text could contain a credential, the details show a generic message instead. To find the cause, click View trace to see the failing step, or View logs to open the trace on its Logs tab. The buttons appear a few seconds after the run ends, once its trace is saved.
List and Follow Runs from Your Own Tooling
To list runs, send a GET request to /api/v1/workspaces/<WORKSPACE>/deployments/<DEPLOYMENT_ID>/executions?status=active. Use status=history for finished runs. A page holds 20 runs by default and up to 50 with limit. To get the next page, pass the response's next_before value as before.
To follow a run, send a GET request to the stream link in the run's links. Every chunk carries an event_id. If the connection drops, reconnect with ?after=<EVENT_ID>, where <EVENT_ID> is the ID of the last chunk you got. The store keeps the last 100 chunks of a run, for 1 hour after the run ends. If you missed more than that, you get a gap frame. Then read the run's details for its current state.
The stream ends with one closing frame:
- A completed run sends a
resultframe with the result, then adoneframe. - A failed or canceled run sends an
errorframe whosestatusisfailedorcanceled. - A waiting run sends a
waitingframe. See Answer a Waiting Run. - If the connection broke, you get an
errorframe whoseerror_categoryisstream_interruptedand that has nostatus. Reconnect withafter. - If the run no longer exists or the
aftervalue is invalid, you get anerrorframe without astatus. Don't reconnect.
Answer a Waiting Run
When an Agent in the run asks a question, the run waits with the status waiting, and the question is in its waiting.message field. For when an Agent can ask, see Durable Runs That Wait for Input. You answer through the API or over A2A. Runs lists the waiting run, but it doesn't show the question or take an answer.
To answer, send a POST request to the run's resume link with the body {"text": "<ANSWER>"}. The link is in the run's links, for example /api/v1/workspaces/<WORKSPACE>/deployments/<DEPLOYMENT_ID>/executions/<EXECUTION_ID>/resume. The run gets your answer exactly as you send it.
The route answers with:
202when the run is queued again.200when a cancel was requested before the run started to wait. The run is canceled instead.404 execution_not_foundwhen the service has no run with this ID.409 invalid_transitionwhen the run isn't waiting. Check the run's status before you send the answer again. If two answers arrive at once, the second gets this error.409 execution_expiredwhen the run no longer exists.422when the answer is blank, longer than 1,000,000 characters, or too large to fit in the store next to the saved conversation. Shorten or fix the answer.503 durable_unavailablewhen the durable store can't be reached, or the waiting run has no saved conversation. Retry later. If it keeps failing, cancel the run.
The route takes no idempotency key. If a retried answer arrives after the Agent asked a second question, the retry answers the second question. To answer without that risk, answer over A2A, which uses the messageId as the key.
Cancel a Run
- Open the details of a run that's still active.
- Click Cancel run, and confirm.
- Check the run's status on its details or in Completed runs to confirm that it was canceled.
To cancel from your own tooling, send a POST request to the run's cancel link. The route answers 202 while the run stops and 200 once it has ended. A run that already ended comes back unchanged, so check its status.
A canceled run stops before its next step. A step that is already running, such as a model call or a tool call, finishes first. Anything that step already did in other systems isn't undone. A waiting run is canceled at once.
Pause Durable Runs on a Service
To stop a service from accepting new durable runs, send a PATCH request to /api/v1/workspaces/<WORKSPACE>/deployments/<DEPLOYMENT_ID> with the body {"durable_enabled": false}. You need the services: write permission. The service then refuses new submissions with a 409 durable_not_enabled error, including after a redeploy. For the request details, see Patch Deployment.
Runs already accepted keep going, and a retry of an accepted Idempotency-Key still returns its run. A submission that the service recorded before the pause, but that the store hasn't accepted yet, can still start when you retry it.
To accept durable runs again, send the same request with {"durable_enabled": true}.
Make a Pipeline Safe to Restart
A restarted run repeats the work of earlier attempts. To let your pipeline skip work it already did, map a query_id input in the pipeline's inputs section to the component input that should receive it. Every attempt of the run gets the same ID in that input. Use it as a key to save your own progress. For example, an Agent tool can check whether it already posted a comment for this ID.
Pipelines that don't map query_id get their original inputs unchanged.
Deactivate a Service
When you deactivate a service, it refuses new durable runs with a 409 service_undeployed error. It keeps its run history, and runs already in flight continue. To submit durable runs again, activate the service.
Delete a Service or Workspace That Has Durable Runs
The platform refuses to delete a service or a workspace that has an unfinished durable run, with a 409 durable_runs_unfinished error. Waiting runs count as unfinished.
- Wait for the runs to finish, or cancel them.
- Send the delete request again. It returns 204 and removes the run history too.
The platform also postpones an organization's deletion while any of its durable runs is unfinished. For the request details, see Delete Workspace.
What To Do Next
- Run Scheduled Calls as Durable Runs to submit each scheduled call as a durable run.
- Monitor and Debug a Service to read the trace of a run.
- Connect to a Published Service for other ways to call the service.
Related Information
- Durable Runs
- Run A2A Tasks in the Background to start a durable run from another agent over A2A.
- Configure Service Hosting and Cost
- Generate API Keys
Was this page helpful?