Autonomous episodes
Let agents in one workflow hand work to each other, ask a person when stuck, and decide when the run is finished.
On this page
Most workflows are a fixed pipeline: step A, then step B, then step C. An episode is a run where some agent steps are not fixed in advance. They wait to be invited, and a running agent can choose which agent should work next.
Who this is for: people building a team of agents inside one workflow, for example a router agent that sends each request to a specialist.
What you will do: mark agent steps as invited-only, let agents hand work to each other, decide how the run ends, and choose what happens if an agent gets stuck.
For a chat with one customer (WhatsApp, for example), use Conversation sessions. Sessions can use hand-offs between agents too, but you do not need to set up an episode yourself to get one run per conversation.
Connected pipeline or episode?
You do not pick a workflow type. A run is an episode when any step has Require entry grant turned on. Otherwise it is a normal connected pipeline.
| Connected pipeline (default) | Episode | |
|---|---|---|
| Start | Every step with no depends_on starts at once | The same, plus invited-only steps once they are granted entry |
| Order | Fixed by depends_on | Also decided by agents, who can hand off to other steps |
| Run ends when | Every step has finished | The run is closed (an Episode terminal step finishes) and the work in progress has settled |
| Steps never invited | Must still finish or be skipped | Ignored |
A mixed workflow combines both: a fixed spine (fetch, then report) with optional invited-only agents on the side. Always give a mixed workflow an end (see Avoid stuck runs).
The settings
Open a step's settings and find Episode & handoffs.
| Studio setting | What it does |
|---|---|
Require entry grant (no_auto_start) | The step does not start with the run, even if nothing comes before it. It starts only when something invites it: you grant it at the start, or another agent hands off to it. |
Episode terminal (terminal) | When this step finishes, the run is closed. Works on any step type. |
| Accepts input from | Which steps may send input or a handoff to this step. Empty means anyone. Add step ids under Allowed senders, and turn on Allow human if a person at the start may invite this step. |
| May send to (optional override) | Limits which steps this one may hand off to. Left empty, it is worked out from the other steps' Accepts input from lists. |
| If the agent stops without handing off | Ask a person (default) or Fail the run. See below. |
| Agent may ask a person | Default, Yes, or No. Whether the agent can stop to ask a question or note an assumption. |
| Max questions per run | How many of the agent's questions people may answer for this step in one run. Default 10, between 1 and 100. After that the next question fails the step. |
| Answer within (minutes, optional) | How long to wait for an answer before the step fails |
Build a small team of agents
- Add the agent steps
Add three Agent steps:
router,analyst, andwriter. - Make them invited-only
Turn on Require entry grant on all three.
- Say who may talk to whom
On
analyst, under Accepts input from, addrouter. Onwriter, addanalyst. Nowroutermay hand off toanalyst, andanalysttowriter. - Choose the way in and the way out
Grant
routerentry when you start the run (below). Onwriter, turn on Episode terminal, so the run closes when the writer finishes. - Dry-run and run
Click Dry-run, then Run with a request as the starting input.
You should see
routerrun first, then the agent it chose, thenwriter, and the run complete.
Grant entry at the start
An invited-only step needs an invitation. In Setup → Manual, choose it under Start steps. Through the API, name it in trigger_steps. The value is that step's own input:
{
"command": "start",
"params": {
"trigger_payload": { "topic": "billing" },
"trigger_steps": { "router": { "request": "I was charged twice" } }
}
}If every step that could start is invited-only and none was granted, the run is rejected with "no step can start".
How a handoff works
When an agent finishes, it can choose another step to hand off to, and pass along some data. AgentRuntime then:
- Checks that the target accepts input from this step.
- Makes the target wait for the sender, then bring it into the run.
- Gives the target the data from the handoff when it runs.
You do not need a depends_on link between agents that choose each other at run time. Use depends_on for steps that must always run.
Handoffs carry data; depends_on only sets order. To read another step's output in a prompt, use a template such as {{steps.<step-id>.result.message}}. See Template intellisense.
How the run ends
A run closes when a step marked Episode terminal finishes. Closing does not end the run instantly. AgentRuntime waits until the steps that are in progress have finished, skips the steps that were never invited, and then marks the run Completed.
For a step that must always run at the end, such as a report, give it a depends_on link to the steps before it and turn on Episode terminal.
When an agent stops without handing off
Sometimes an agent replies but does not hand off, and nothing else can run. The run would sit still, so AgentRuntime acts. If the agent stops without handing off decides what:
- Ask a person (default): a task appears in Command Center as Question from the agent, showing the agent's last message. Answer to let the agent continue, or choose End run.
- Fail the run: the run fails with the agent's last message. Use this for runs nobody watches.
Agents that ask questions
An agent can ask a person for input in two ways:
- A question the run waits for: the step pauses until someone answers.
- An assumption: the agent carries on with a guess and asks a person to check it (Looks right, Dismiss, Correct it). The run does not wait. A correction re-runs the step only if nothing after it has started.
Turn this off for an agent with Agent may ask a person: No. See Human tasks.
Safety limit
A run's agents may take 100 turns by default. When they reach the limit, the next agent turn waits for a person (Ask a person) or the run fails (Fail the run). You can let a run carry on up to three times by answering. The limit protects against two agents that keep handing work back and forth. It is set in the workflow JSON as settings.episode.max_agent_turns.
Avoid stuck runs
A mixed workflow has one trap: the fixed spine can finish while the invited-only agents never ran, and nothing closes the run. Prevent it:
- Turn on Episode terminal on the last step of the spine.
- Or add a coordinator agent that is Episode terminal and runs after the spine.
- Or keep fixed pipelines and agent teams in separate workflows.
Common problems
| Problem | What to try |
|---|---|
| The run was rejected with "no step can start" | Every starting step is invited-only. Grant one under Start steps, or name it in trigger_steps. |
| An agent never runs | Nothing invited it. Check Accepts input from on that step, and that another agent's handoff targets it. |
| A run shows Question from the agent | An agent stopped without handing off. Answer it, or switch to Fail the run for unattended runs. |
| The run never completes | No step is Episode terminal. Turn it on for the last step. |
Next steps
- Step types: the
agentstep - Conversation sessions: one run per conversation
- Human tasks: answering agent questions
- Dry-run validation