Durable Runs That Wait for InputBeta
A durable run can pause when an Agent needs a person's answer before it can continue. When the Agent asks the user a question with its ask_user tool, the durable run doesn't finish. It waits for the answer, needs no pod until you answer, and continues its conversation once you do. If nobody answers, the run stays unfinished until it expires. Waiting runs need a runtime that supports pausing.
When a Run Can Ask
Only the Agent that the pipeline's messages input feeds can wait for an answer. The Agent asks by calling a tool named ask_user with a non-empty question. Durable runs reserve the tool name ask_user: in a durable run, the tool's own function never runs. Instead, the run stops before the tool runs and waits.
The run fails instead of waiting in these cases:
- The
ask_usercall comes from an Agent that themessagesinput doesn't feed: another Agent in the pipeline, an Agent inside another component, or an Agent that's another Agent's tool. - The pipeline has no
messagesinput. - The asking Agent has a
user_prompt. After you answer, the Agent would render that prompt again. - The call has no
question, or the question is empty. - The conversation is too large for the durable store (1 MB by default).
A failed run is recorded in search history like any other failed run.
If the model requests other tool calls in the same step as ask_user, those calls don't run.
What Happens When You Answer
After you answer, the run starts again with the conversation so far, which ends with the question, and your answer as the messages input. Tool calls from before the question don't run again. If an attempt is restarted after you answered, it gets the same answer again. Answering doesn't reset the restarts the run has left.
A run that works in a named session saves the session before it waits, so the resumed run restores the latest workspace.
The run has one search history record, which pairs the submitted query with the final answer. The question and your answer aren't part of it.
Waiting Status
A run that waits has the status waiting, and the question is in the run's waiting.message field. The run's body links resume, the route you use to answer. A waiting run is also listed in the Active list on the service's Runs tab, and you can cancel it like any other unfinished run. Canceling a waiting run ends it at once, without another attempt.
Answering a Waiting Run
To answer, send a POST request to the resume link of the waiting run, for example /api/v1/workspaces/<WORKSPACE>/deployments/<DEPLOYMENT_ID>/executions/<EXECUTION_ID>/resume, with the body {"text": "<ANSWER>"}. The answer is passed on exactly as you send it. You need the same permissions as for canceling a run: the search-history: read and services: write permissions.
The route answers with:
202when the run is queued again.200when the run was canceled instead, because a cancel was requested before it started to wait.409when the run isn't waiting. Check the run's status before you send the answer again. The second of two answers sent at once gets this response.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.503when the durable store can't be reached (retry later) or the waiting run has no saved conversation (retrying doesn't help: cancel the run).
Streams of a Waiting Run
A stream of a run that waits ends with a waiting frame instead of staying open. The frame carries the run's links, including resume, so a client that only streams knows where to send the answer. After you answer, open the stream again to follow the resumed run.
Unanswered Runs
A run that nobody answers is canceled after 7 days by default, up to about 10 minutes late, and then reads as canceled, like a run you cancel yourself. A second question starts a new 7 days. Until then, a waiting run counts toward the durable store's cap of unfinished runs and keeps its service from being deleted. To free the slot sooner, cancel the run.
A2A can't send an answer yet: an A2A task whose run waits is reported as working.
Related Information
Was this page helpful?