Skip to main content

Agent node - exits

Exits are how an Agent node step finishes. Exits exist only on Agent nodes inside a multi agent. Each exit is a branch on the flow canvas, and the flow follows the one the step takes.

Example: in a Returns flow, the Return request step leaves on return_approved once returnApproved is yes. If the customer asks for a replacement instead, the agent leaves on wants_replacement.

The Returns flow canvas, with the Return request step and its return_approved, wants_replacement and On error branches

Exits​

Open the agent step and go to Exits. Click + Add exit to add one. On error is always there.

ExitWho decidesExample
Variable ruleA variable's value.return_approved: when returnApproved is yes
Agent outcomeThe agent, from your descriptionwants_replacement: the user would rather have a replacement
Tool exitThe agent, by running a toolRaise an escalation ticket
Leave after one replyNobody. The step leaves after one reply.Summarise a result, then move on
On errorThe system, when the agent failsApologise and hand to a person

A step can have up to five variable rules and agent outcomes in total.

Exit or variable? An exit decides where the conversation goes next. A variable decides what the rest of the flow knows. Most steps need both. See Variables and exits.

When no exit applies​

Drag a rule to change its order. Write rules that can't both be true.

If no exit applies, the conversation stays in this step.

Add a variable rule​

The Return request step runs a Check return eligibility tool, which saves its answer to returnApproved. A rule moves the flow on once the variable is set.

  1. Open the Return request step and go to Exits.
  2. Click + Add exit → Variable rule.
  3. Under Name, enter return_approved. This is the branch name on the canvas.
  4. Under Leave when, pick returnApproved, the operator is, and the value yes. Click + Add condition to add more.
  5. Save, then connect return_approved to the next step, Confirm the return.

The Exits panel of the "Return request" step, with a variable rule "return_approved", an agent outcome "wants_replacement", and On error

The variable rule editor for "return_approved", with Leave when returnApproved is yes

Something must set the variable

Let the agent fill it (see Allowed variables), or set it from a tool or a lifecycle hook. If nothing in the step sets it, the canvas warns: "Nothing in this step writes the variable for: <rule>".

  • Don't use only rules. If no rule comes true, the user is stuck. Add an agent outcome, a tool exit or Leave after one reply too.

Agent outcome​

The agent decides when it applies.

Agent outcomes are the most common exit. You give each one a name and a description. When the agent finishes its job, it picks the outcome that matches the situation.

FieldWhat it's for
NameA short snake_case identifier, such as billing_issue, eligible or max_retry. This is the branch name on the canvas.
When the agent should pick itNatural language that tells the agent when this outcome is true, for example "user confirmed the refund".

The agent matches on the description. The name is only a label. Vague descriptions lead to wrong branches. Clear, mutually exclusive descriptions lead to reliable ones.

  • Make them mutually exclusive. "if the intent is a return" and "if the intent is an exchange" don't overlap. "if the customer seems unhappy" and "if there's a problem" do overlap, and the agent can't choose reliably between them.
  • Describe the condition, not the destination. Write "if the user wants a different size", not "go to the exchange handler". The canvas decides where the branch goes.
  • Cover the unhappy paths. Add branches for "outside what this step handles" and "the user asked for a human". Otherwise those cases go down one of your main branches.
  • Keep the set small. Use two to five outcomes. If you need ten, the step is doing too much.

Example: a returns router.

Branch nameDescription
returnif the customer wants to send an item back for a refund
exchangeif the customer wants to swap an item for a different size or variant
out_of_scopeif the request is about anything other than a return or an exchange
max_retrywhen the customer can't decide after 3 attempts

Rules for names

  • Names change to lowercase snake_case as you type.
  • Some names are reserved. The editor tells you if you pick one.
  • You can rename a branch safely. Its line stays connected.
  • Two branches can't share a name. The drawer flags the duplicate.

If a step keeps talking, no outcome matches yet. Make the descriptions or the Instructions more specific.

Leave after one reply​

For a single answer with no follow-up.

The step sends one reply and returns control to the flow. The agent makes no choice, so there is only one next step.

Use it for a step that only needs to say something: acknowledge, summarise, or explain a result from the previous step. It is the most predictable exit. Use it instead of a step with a single branch called done.

You can add one Leave after one reply per step.

Tool exit​

Leaves after the agent runs a tool.

The step finishes when the agent calls a tool you choose. The flow then follows that tool's branch.

An agent outcome and a tool exit differ:

  • An agent outcome reports a conclusion. "It's a return."
  • A tool exit takes an action that ends the step. "Raise the ticket." "Transfer to a human."

Use a tool exit when the action and the outcome are the same event, and the flow continues from what the action produced. Escalation is a common example: the agent calls the escalation tool, and that ends the step.

You can use only tools attached to this step as a tool exit. The picker offers no others.

Rules for tool exits

  • If the tool fails, the step doesn't take the exit.
  • Some names are reserved and can't be used as tool exits. The editor tells you if you pick one.

On error​

When the agent can't finish this step.

On error is always present and you can't edit it. It is the fallback path, not an exit you design.

The agent never chooses On error. The step takes it when the agent fails.

Connect it. Send it to a step that recovers, such as an apology plus a human handoff, or a retry step. If On error has no line, the flow ends.

Don't use On error for business failures such as "not eligible" or "payment failed". Give those a branch.

Build a retry limit​

There is no retry exit and no built-in attempt counter. max_retry appears in many examples on this page, but it is an ordinary agent outcome named max_retry. A name such as gave_up behaves the same way.

A retry limit needs two parts:

  1. The branch: an agent outcome named max_retry, with the description "when the customer still hasn't given a valid postcode after three attempts".
  2. The instruction that reaches it: "If they can't give a valid postcode after three attempts, finish on max_retry."

If you add only the branch, it never fires, because nothing counts attempts for you. If you add only the instruction, the agent has no branch to take when it stops. Add both.

The agent estimates the count from the conversation. Treat it as about three attempts, not exactly three. For an exact limit, count attempts in a variable and add a variable rule such as "attempts is 3".

Connect max_retry to a different path, such as a human handoff, a simpler fallback question, or an apology and an exit from the flow. If you connect it back to the same step, the loop starts again.

Other common branch names, such as out_of_scope, declined and completed, are also ordinary agent outcomes.

Choose an exit​

You want the step to…Use
Leave as soon as a variable says soVariable rule
Decide between two or more outcomesAgent outcomes
Say one thing and move onLeave after one reply
End by doing something (escalate, raise a ticket, transfer)Tool exit
Give up after too many attemptsAn agent outcome named max_retry, plus an instruction that reaches it. Or count attempts in a variable and use a variable rule.
Handle a step the agent can't finishOn error. It is already there; connect it.

Design the exits​

Design the exits first. The Instructions, variables and canvas lines all depend on one question: "How can this step end?"

Start from the Goal​

The Goal says what the step must achieve. The exits list the ways the Goal can end, including the bad ones. The Goal and the exits must match.

Aligned. Goal: "Confirm whether the customer wants to go ahead with the refund, and record their decision."

BranchDescription
refund_confirmedthe customer has clearly agreed to the refund
refund_declinedthe customer has decided against the refund
escalatethe customer asks for a human, or disputes the amount
max_retrythe customer won't give a clear answer after 3 attempts

Each branch is a way the Goal can end. No branch is missing and no branch is extra.

Not aligned. The Goal is the same, but the exits are visa, mastercard, amex and paypal. These are not ways the Goal ends. They describe the payment, not the decision. Store this information in a variable instead.

Check two things:

  • An exit that doesn't match a way the Goal can end is probably data. Use a variable.
  • A way the Goal can end with no exit is a gap. The usual gaps are the customer declining or asking for a human.

Name exits for your business​

Branch names are not generic. return and exchange are the names in the examples on this page. Name your branches for what happened in your business:

StepSensible branches
Confirm a refundrefund_confirmed, refund_declined, escalate
Verify identityverified, verification_failed, customer_abandoned
Offer a retention dealoffer_accepted, offer_rejected, wants_to_cancel_anyway
Book an appointmentslot_booked, no_slots_suitable, needs_callback
Triage a faultresolved_by_self_service, needs_engineer_visit, needs_replacement

Specific names make the canvas and the logs easy to read. If every step uses completed and failed, a run is hard to follow.

When it's an exit, and when it's a variable​

Ask one question: does the flow go somewhere different?

The step establishes…Exit or variableWhy
Whether a refund was approvedExitApproved and declined lead to different work.
Which card the customer paid withVariableUseful to record, but the next step is the same.
Whether the customer is eligibleExitEligible and ineligible customers take different paths.
Their delivery addressVariableThe flow carries the information forward. It doesn't branch on it.
Which of 200 products they're asking aboutVariableAlways a variable. See below.
Which department they need, with 4 departments that each have their own flowExitFour outcomes, four destinations. That is routing.
Their reason for cancelling, from a long listVariableIf a few specific reasons need different handling, use a small set of exits plus a variable for the detail.

The last row is the most common pattern: a few exits for the paths that differ, plus a variable for the detail. You can use both.

Don't create an exit per value​

Don't add one branch per possible value, such as a branch per product, country or reason code. This design fails in five ways:

  1. A step has at most five branches. An entity with twelve values doesn't fit.
  2. You draw and maintain every branch. Forty values means forty lines, and most go to the same place.
  3. The agent works best with a few distinct outcomes. It can't reliably tell thirty similar ones apart.
  4. Each new value needs a flow change. A new product line means you edit and republish the flow. A variable accepts new values with no change.
  5. The canvas becomes hard to read. A readable canvas is the reason to build a multi agent instead of a single agent.

Any one of these checks settles it:

  • Do all the branches go to the same next step? Then they are a value, not outcomes.
  • Can a new value appear next month without a flow change? Then it is a value. Outcomes are a closed set that you define. Entities are open.
  • Can you write a distinct description for each branch? If each reads "the customer said X" and only X changes, use one outcome and a variable.

Use one branch pair and one variable:

Branchesproduct_identified, product_unclear
Variableproduct_name, set to Agent fills this

You connect one line, the variable holds any product, and a later step reads it.

When the branches go to ten different places​

Sometimes the ten destinations are different places, and no entity is involved. The design is valid, but it doesn't fit in one step.

You find this at the sixth branch, because the limit is five. Treat the limit as a design signal.

First, check whether you need a flow. A multi agent enforces an order. Ten independent use cases have no order between them. Nobody checks a balance and then reports a lost card. In that case, give each use case its own single agent with a clear trigger, and let routing choose. This scales to any number of use cases, needs no canvas, and handles a customer who changes topic mid-conversation.

Build a router flow only when you need one of these:

  • Entitlement gating: offer only what this customer is allowed to use.
  • A fixed script: regulated or brand-mandated wording.
  • A guaranteed menu: the same options in the same order every time.

If you need a router, use two levels. Group the destinations into a few categories, and let each category step choose among its own items. No step has more than four or five branches, and twelve destinations fit.

Two levels also suit the customer. A ten-item menu is hard to read and hard to use on a phone call. Two questions with four options each work better than one question with ten.

Or classify into a variable and dispatch on it. When there are many destinations and the routing is mechanical, split the work. The agent understands what the customer means, and the flow does the dispatch.

The Agent node has two exits, identified and unclear, and writes the choice to a variable. A Condition node then routes on that value, with one arm per destination.

To add an eleventh service later, add a condition arm and a line in the agent's Instructions. The step's exits don't change, so you never reach the limit, and the dispatch is deterministic.

SituationDo this
Independent use cases, no fixed orderDon't build a router flow. Use single agents with triggers.
Entitlement gating, a script, or a guaranteed menu, with about 6-12 destinationsTwo levels. Easier to maintain, and better on voice.
Many destinations, mechanical dispatch, a list that growsClassify to a variable, dispatch with a Condition node.
Two to five outcomesOne step with branches.

In every case, routing happens on the canvas. Writing "if they choose 3, send them to the appraisal agent" in a step's Instructions has no effect. See You cannot route to another agent from the Instructions.

Other ways a step can end​

Some endings are not exits. They don't take a branch, so a step can finish with no line followed.

What happensResult
The call is transferred or ended (voice)If the step, or a tool it calls, transfers or ends the call, the call leaves. The flow doesn't continue to a next step.
Routing moves the customer out of the flowIf the customer asks about something unrelated to the flow, your AI agent's routing can move them out of the flow. The flow stops. No exit is taken and no branch fires.
The step is waiting (not an ending)The agent replied without choosing an exit, so the step waits for the next message. This is expected behaviour.

A customer can leave a flow to ask about something else. Design for the conversation continuing elsewhere. Don't assume every run reaches one of your exits.

An exit with no line ends the flow​

Each exit you add appears as a handle on the step in the flow canvas, and the flow follows the one the step takes. An exit with no line shows No line. The flow ends here.

When the step leaves on an exit with no line:

  • A variable rule, agent outcome, tool exit or Leave after one reply: the flow ends there. It doesn't run the On error line.
  • On error: the flow follows the On error line. If On error has no line either, the flow ends.
  • In a sub-flow: only the sub-flow ends. The parent flow continues.
  • Make sure every exit leads to a step that replies.

Leave an exit unconnected only on purpose.

Later steps can't read which exit was taken​

An exit steers the flow and does nothing else. No later step can read which exit an earlier step took. If a later step needs to know that this step concluded return rather than exchange, also save that decision in a variable.

If a later step works out the decision again from the conversation, it can reach a different answer, and the error is hard to find.

You cannot route to another agent from the Instructions​

Writing "mark this goal complete and route to @Some Other Agent" in an Agent node's Instructions does not route anywhere. In a multi agent, the canvas controls the order.

Add a branch for that outcome, and on the canvas connect the branch to the step you want. The agent reports which outcome happened. The canvas line decides where it goes.

Common problems​

PatternWhat goes wrong
A branch with no instruction that reaches itThe branch never fires. This often happens to max_retry: the branch exists, but nothing tells the agent to take it.
Overlapping descriptionsThe most common cause of a step that routes inconsistently. If two descriptions can both be true for one message, the agent can't choose reliably.
Descriptions that name the destination"go to the refund handler" describes the canvas line, not the situation. The agent matches on what is true now.
A branch per possible valueExits used as data. See Variables and exits.
Only happy-path branchesA customer who wants a human, or asks something off-topic, goes down a branch that doesn't fit.
An exit with no lineThe flow ends there. This is fine on purpose and a problem by accident. On error is the exit most often left without a line.
Expecting On error for business failures"Not eligible" is an outcome, not an error. Give it an agent outcome or a rule.
Ten branchesThe step is doing too much, and the limit is five.

Best practices​

  • Design the exits before you write the Instructions. The exits define what the step reports to the rest of the flow. Each instruction then leads to a branch.
  • Write descriptions as mutually exclusive conditions. The agent matches on the description. The name is only the handle for the line. If two descriptions can both be true, the step behaves inconsistently.
  • Trace each branch back to the Instructions. For every exit, find the sentence in the Instructions that leads to it. If there is no sentence, the exit doesn't fire.
  • Give every ending a destination, including the bad ones. Cover unhappy paths, the give-up path and On error. An exit with no line ends the flow.
  • Use two to five branches. With fewer than two, consider Leave after one reply. If you need more, split the step.