OptionaldeciderDescription: stringOptionalfn: StageHandler<TOut, TScope>Optionaldescription: stringOptionaloptions: {{ loopTo } declares this branch loops back to an already-declared
stage — the loop is SOURCED FROM THIS BRANCH (not the decider).
{ retry } gives THIS BRANCH's stage a declarative retry policy;
{ tags } puts declared tags on it (see FlowChartBuilder.tag).
OptionalmountName: stringOptionaloptions: SubflowMountOptions<any, any, any>Add a pausable stage as a decider branch.
When this branch is chosen, the handler's execute runs. If it returns
data, the pipeline pauses. On resume, handler.resume runs with the
human's input. If execute returns void, the stage continues normally
(conditional pause).
Optionaldescription: stringOptionaloptions: {{ loopTo } declares this branch loops back to an already-declared
stage — the loop is SOURCED FROM THIS BRANCH (not the decider).
{ retry } gives THIS BRANCH's execute half a retry policy (the
resume half runs without it — a different function, a different
contract); { tags } puts declared tags on it.
OptionalmountName: stringOptionaloptions: SubflowMountOptions<any, any, any>Attach a loop-back edge to the LAST-added branch, so the loop is sourced
from THAT branch node (e.g. 'tool-calls' → loopTo('context')) rather than
from the decider. The chart then reads honestly: the decider splits into a
looping branch [ToolCalls → back to Context] and a terminating branch
[Final → end], instead of a single loop hanging off the decider.
No engine change is needed: the runtime runs the chosen branch and then
follows that branch node's OWN next — and a next flagged isLoopRef
routes back to the target exactly like the decider's own loop does. This
method just lets the builder express what the engine already supports.
Targets the branch added immediately before this call (chain it right after
the branch's addFunctionBranch/addPausableFunctionBranch/
addSubFlowChartBranch). Mirrors FlowChartBuilder.loopTo validation.
Works on a SUBFLOW branch too: the branch node carries both its subflow
resolver AND the loop-back next — they coexist safely (the runtime runs
the subflow, then follows the loop ref). The target must be a stage already
declared BEFORE the decider (e.g. an upstream context); branch ids and the
synthetic 'default' clone are NOT valid loop targets.
Name the branch taken when no branch id matches. end() refuses an id that names no branch of this decider.
Fluent helper returned by addDeciderFunction to add branches.
end()setsdeciderFn = true— the fn IS the decider.