Navigation and Flow Control#
Parent document: YAML Reference Epic: DOC-002 (YAML Reference Modularization)
Overview#
TEA supports two navigation approaches: the modern implicit/goto syntax (recommended) and the legacy edges section (deprecated for sequential flows). This document covers both approaches.
Table of Contents#
Implicit Chaining (Default)#
By default, nodes execute in the order they are defined. After a node completes:
If the node has a
gotoproperty, use itOtherwise, proceed to the next node in the list
If it’s the last node, the workflow ends (
__end__)
name: implicit-flow
nodes:
- name: step_a
run: |
return {"message": "Step A done"}
- name: step_b
run: |
return {"message": "Step B done"}
- name: step_c
run: |
return {"message": "Step C done"}
# No edges needed - implicit flow: step_a -> step_b -> step_c -> __end__
The goto Property#
The goto property on a node specifies the next node to execute. It can be:
String: Unconditional jump to a specific node
Array: Conditional jump with if/to rules
Unconditional goto#
Jump directly to a named node:
nodes:
- name: start
run: |
return {"initialized": True}
goto: validate # Skip to validate, not next node
- name: skipped_node
run: |
return {"this": "is skipped"}
- name: validate
run: |
return {"validated": True}
Special goto Targets#
Target |
Description |
|---|---|
|
Terminate workflow immediately |
Node name |
Jump to the named node |
(omitted) |
Use implicit chaining (next in list) |
Conditional goto#
Use a list of rules for conditional branching. Each rule has:
if(optional): Boolean expression to evaluateto(required): Target node if condition is true
Rules are evaluated in order; the first matching rule wins.
nodes:
- name: validate
run: |
score = check_quality(state["input"])
return {"score": score}
goto:
- if: "state.score > 0.9"
to: high_confidence
- if: "state.score > 0.5"
to: medium_confidence
- to: low_confidence # Fallback (no condition = always true)
- name: high_confidence
run: |
return {"path": "high"}
goto: __end__ # Terminate early
- name: medium_confidence
run: |
return {"path": "medium"}
- name: low_confidence
run: |
return {"path": "low"}
Context Variables in Conditions#
Variable |
Description |
|---|---|
|
Global agent state (includes merged node results) |
|
Template variables from YAML |
|
Secret values (if configured) |
Note: Node execution results are automatically merged into
statebeforegotoevaluation. Access returned values viastate.field_name(e.g., if node returns{"score": 90}, usestate.score).
Loops with goto#
Use conditional goto to create loops:
nodes:
- name: retry_step
run: |
result = attempt_operation()
attempts = state.get("attempts", 0) + 1
return {"status": result.status, "attempts": attempts}
goto:
- if: "state.status == 'error' and state.attempts < 3"
to: retry_step # Loop back
- if: "state.status == 'ok'"
to: success
- to: failure # Max retries exceeded
- name: success
run: |
return {"final": "success"}
goto: __end__
- name: failure
run: |
return {"final": "failed"}
goto: __end__
Navigation Precedence#
When multiple navigation methods are present, precedence is:
gotoproperty on node (highest priority)edgessection (legacy, deprecated)Implicit chaining (next node in list)
# Example: goto takes precedence over edges
nodes:
- name: step_a
goto: step_c # This wins
- name: step_b
- name: step_c
edges:
- from: step_a
to: step_b # Ignored because goto exists
Migration from Edges#
To migrate from the legacy edges format:
Legacy Pattern |
New Syntax |
|---|---|
Linear edges (A→B→C) |
Remove edges, use implicit chaining |
|
Not needed, first node is entry point |
|
Not needed for last node, or use |
Conditional edges |
Use |
Unconditional jump |
Use |
Parallel edges |
Keep as-is (not deprecated) |
Note: Parallel edges with
parallel: trueandfan_in:are not deprecated and should remain in theedgessection. Only sequential navigation edges are being migrated togoto.
See TEA-YAML-002 (Implicit Graph Goto Syntax) for the full migration guide and LLM prompt.
Edge Specification (Deprecated)#
Deprecation Notice: Sequential edges are deprecated in favor of implicit chaining and
gotoproperties. See sections above for the modern syntax.Exception: Parallel edges (
parallel: true,fan_in:) are not deprecated. They remain the only way to define fan-out/fan-in execution patterns and will continue to be supported.Deprecation Roadmap (Sequential Edges Only):
v0.8.x (Current): Sequential
edgeswork normally, emit INFO-level warningv1.0.x: Sequential
edgeswork, emit WARNING-level warning with migration linkv2.0.x: Sequential
edgesrejected with error, must usegotoor implicit
Basic Structure#
edges:
- from: string # Source node (or __start__)
to: string # Target node (or __end__)
# Optional:
type: string # Edge type: normal | parallel
condition: object # Conditional routing
when: any # Simple condition shorthand
fan_in: string # Fan-in node for parallel edges
Edge Types#
Simple Edge#
- from: node_a
to: node_b
Entry Point#
- from: __start__
to: first_node
Finish Point#
- from: last_node
to: __end__
Conditional Edge#
Route based on expression evaluation:
# Method 1: Expression condition
- from: validate
to: process
condition:
type: expression
value: state["is_valid"] == True
when: true
- from: validate
to: error_handler
condition:
type: expression
value: state["is_valid"] == True
when: false
# Method 2: Simple when clause
- from: check
to: proceed
when: "state['count'] > 0"
# Method 3: Variable reference with negation
- from: check
to: skip
when: "!should_process"
Parallel Edges#
Execute flows concurrently (NOT deprecated):
# Define parallel flows
- from: start
to: flow_a
type: parallel
fan_in: combine
- from: start
to: flow_b
type: parallel
fan_in: combine
- from: start
to: flow_c
type: parallel
fan_in: combine
# Continue after fan-in
- from: combine
to: next_step
Parallel edges require:
type: parallelon each parallel branchfan_in: node_namespecifying the node that collects resultsA fan-in node marked with
fan_in: truein the nodes section
See Also#
Node Specification - Node configuration and execution methods
Template Syntax - Variable interpolation in conditions
Actions Overview - Built-in action reference