Esta página no está disponible en español. Se muestra la versión en inglés.

Autonomous episodes

Let agents in one workflow hand work to each other, ask a person when stuck, and decide when the run is finished.

En esta página

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.

Nota

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
StartEvery step with no depends_on starts at onceThe same, plus invited-only steps once they are granted entry
OrderFixed by depends_onAlso decided by agents, who can hand off to other steps
Run ends whenEvery step has finishedThe run is closed (an Episode terminal step finishes) and the work in progress has settled
Steps never invitedMust still finish or be skippedIgnored

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 settingWhat 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 fromWhich 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 offAsk a person (default) or Fail the run. See below.
Agent may ask a personDefault, Yes, or No. Whether the agent can stop to ask a question or note an assumption.
Max questions per runHow 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

  1. Add the agent steps

    Add three Agent steps: router, analyst, and writer.

  2. Make them invited-only

    Turn on Require entry grant on all three.

  3. Say who may talk to whom

    On analyst, under Accepts input from, add router. On writer, add analyst. Now router may hand off to analyst, and analyst to writer.

  4. Choose the way in and the way out

    Grant router entry when you start the run (below). On writer, turn on Episode terminal, so the run closes when the writer finishes.

  5. Dry-run and run

    Click Dry-run, then Run with a request as the starting input.

    You should see router run first, then the agent it chose, then writer, 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:

  1. Checks that the target accepts input from this step.
  2. Makes the target wait for the sender, then bring it into the run.
  3. 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

ProblemWhat 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 runsNothing invited it. Check Accepts input from on that step, and that another agent's handoff targets it.
A run shows Question from the agentAn agent stopped without handing off. Answer it, or switch to Fail the run for unattended runs.
The run never completesNo step is Episode terminal. Turn it on for the last step.

Next steps

Editar esta páginaagentruntime-io/agentruntime-docs