Skip to main content
Available Control Flow Nodes:
  • Router Node - Route execution based on condition matching with multiple named paths
  • Decision Node - LLM-powered intelligent routing based on natural language criteria
  • Human-in-the-Loop Node - Pause execution and request a human decision before proceeding

Router Node

The Router Node evaluates a condition and routes pipeline execution to one of multiple named paths. It uses template-based conditions (similar to Jinja2 syntax) to determine which route to take, with a default fallback route if no conditions match. Router Node Interface Purpose Use the Router Node to:
  • Route execution to different paths based on state variable values
  • Implement branching logic with multiple named routes
  • Evaluate complex conditions using template syntax
  • Provide fallback behavior with default output
  • Create multi-path workflows based on data conditions
  • Create loops and iterative execution by routing back to previous nodes
Parameters Router Node Interface
Route names in the condition must exactly match node IDs in the pipeline. Case sensitivity matters: “ArticlePublisher” ≠ “article_publisher”.
YAML Configuration
The Router Node uses Jinja2-like template syntax for condition evaluation. Here are common patterns:String Matching:
Multiple Conditions with elif:
Logical Operators:
Numeric Comparisons:
String Filters:
Complex Conditions:
The Router evaluates the condition from top to bottom. When a condition matches, it returns the associated route name and execution proceeds to that node. If no conditions match, execution goes to the default outputRouter nodes can create loop structures by routing back to previous nodes. This enables iterative processing by:
  • Routing to an earlier node when a condition is met (e.g., counter < max_iterations)
  • Routing to the next node or END when the loop should exit
  • Using state variables to track iteration count and control loop termination
This is an alternative to Loop and Loop from Tool nodes, offering more precise control over loop conditions and execution flow.
Best Practices
  • Always Provide Default Output: Ensure fallback behavior for unmatched conditions to prevent pipeline failures.
  • Match Route Names Exactly: Route names in condition must match node IDs exactly (case-sensitive).
  • Order Conditions by Specificity: Place most specific conditions first to avoid unintended matches.
  • Use Filters for String Comparisons: Normalize strings with |lower or |upper for reliable matching.
  • List All Routes: Include all possible routes in the Routes list for clarity and validation.
  • Test All Paths: Ensure every condition path is reachable and test edge cases.
  • Use Descriptive Route Names: Name routes clearly to indicate their purpose (e.g., “ApprovedWorkflow” not “Path1”).
  • Document Complex Conditions: Add comments in YAML to explain routing logic for maintainability.
  • Use Router for Loop Control: When creating loops, use state variables (counters, flags) to control loop termination and prevent infinite loops.

Decision Node

The Decision Node uses LLM intelligence to make routing decisions based on natural language criteria. It operates as a standalone node in the pipeline and analyzes the input to intelligently select the appropriate output path from multiple decision outputs. Decision Node Interface Purpose Use the Decision Node to:
  • Make intelligent routing decisions using LLM reasoning
  • Route based on natural language criteria without writing conditions
  • Handle complex decision logic that’s difficult to express in templates
  • Leverage context and semantics for routing decisions
  • Simplify decision-making with descriptive instructions
Decision Nodes are slower than Router nodes due to LLM processing. Use for complex routing requiring semantic understanding, not simple condition matching.
Decision nodes cannot be connected to another Decision node. If you need sequential decision-making, use a different node type (such as Router, LLM, or Code) between Decision nodes.
Parameters Decision Node Interface YAML Configuration
The Decision Node operates as a standalone node that uses LLM to:
  1. Read input state variables (configured in input parameter)
  2. Analyze description for routing criteria
  3. Select appropriate output from nodes list
  4. Return selected node ID for routing
  5. If uncertain, defaults to default_output
Best Practices
  • Write Clear Decision Criteria: Provide specific, unambiguous routing rules with examples for each path.
  • Provide Examples in Description: Help the LLM understand expected routing with concrete examples.
  • Always Define Default Output: Provide fallback for unclear cases to prevent pipeline failures.
  • List All Decision Outputs: Include all possible routing targets in the nodes list.
  • Structure Descriptions Clearly: Use headings, lists, and clear formatting to organize routing criteria.
  • Use Decision Node for Complex Routing: Choose when routing requires semantic understanding, not simple condition matching.
  • Configure Input Variables: Include relevant state variables in input for the LLM to analyze.
  • Test with Various Inputs: Verify LLM routing across different scenarios and edge cases.
  • Monitor Decision Quality: Review LLM routing decisions periodically and refine description if needed.
  • Provide Context in Description: Help the LLM make better decisions by explaining the use case.
  • Use Descriptive Output Names: Name outputs clearly to match description (e.g., “TechnicalSupport” not “Output1”).
  • Use Interrupts for Debugging: Enable interrupts to review decision-making and routing results during development.

Human-in-the-Loop Node

The Human-in-the-Loop (HITL) Node pauses pipeline execution and waits for a human decision before continuing. It presents a configurable message to the user and provides up to three action buttons — Approve, Edit, and Reject — each routing to a different downstream node. HITL Purpose Use the HITL Node to:
  • Gate critical actions — require human sign-off before irreversible steps
  • Validate AI output — let a human review and approve content generated by previous nodes
  • Allow human correction — give users the ability to edit a state value before the pipeline continues
  • Implement approval workflows — build multi-step review processes where humans are in the decision path
  • Enforce compliance checkpoints — ensure sensitive operations are authorized by a person
Parameters hitl
The Edit action is only available to users when both conditions are met:
  1. edit_state_key is set to a valid state variable name.
  2. Edit route is configured and does not point to END.
If either condition is missing, the Edit button will not appear in the UI.
How It Works
  1. The node builds the user-facing message from the configured user_message.
  2. Pipeline execution pauses using LangGraph’s dynamic interrupt mechanism.
  3. The UI displays the message along with action buttons for each configured route.
  4. The user chooses an action:
  5. Execution continues from the target node.
YAML Configuration
The HITL node uses LangGraph’s Command(goto=) pattern for routing — no explicit transition field or conditional edges are needed. All route target nodes must exist in the pipeline.

UI Behavior

When the pipeline reaches a HITL node during a run, the chat panel displays the configured user message and action buttons for each configured route. Only buttons with valid routes appear. After the user clicks an action, the pipeline resumes automatically. Approve Appears when: the approve route is configured.
  • The Approve button signals that the user accepts the content or action as-is. Clicking it immediately resumes the pipeline and routes execution to the node specified in approve. No state variables are modified — the pipeline continues with the same state it had when it paused. Approve
Use this when: the generated output is correct and ready for the next step (e.g., publishing content, creating a ticket, sending a notification). Edit Appears when: both an edit route and a valid edit_state_key are configured (and the Edit route does not point to END).
  • The Edit button allows the user to revise a specific piece of content before the pipeline continues. Clicking it opens a text input field pre-filled with (or adjacent to) the current value of the edit_state_key state variable. After the user submits the revised text, the pipeline updates edit_state_key with the new value and routes execution to the node specified in edit. Edit
Use this when: the output is mostly correct but needs minor adjustments — for example, rewording a ticket description or correcting a generated summary — without restarting the full generation process. Reject Appears when: the reject route is configured.
  • The Reject button (red) signals that the user has declined the content or action entirely. Clicking it resumes the pipeline and routes execution to the node specified in reject — typically END to cancel the workflow, or a regeneration node to start over. No state variables are modified. Reject
Use this when: the output is unacceptable and the pipeline should be stopped or fully restarted rather than edited inline.
  • The Edit route cannot point to END.
  • edit_state_key must be set for the Edit button to appear; it must reference a state variable that already exists.
  • Because HITL uses a dynamic interrupt, the pipeline must be running with checkpoint/memory support (a thread_id must be active) for the resume to work correctly.
  • Each HITL node can handle only one pending interrupt at a time.
  • The node does not modify state on Approve or Reject — only Edit mutates state.
Best Practices
Always gate destructive or hard-to-undo operations:Good:
Show users the content they are reviewing:Good:
If the user’s edited value needs to be re-processed by an LLM, route Edit to a node earlier in the pipeline:
Without a Reject route, users cannot decline an action. Set it to END or a recovery node:
Real-Life Usage Examples
An LLM generates a blog post draft. A human reviews it, approves it for publishing, edits the draft directly, or rejects it to trigger a full regeneration.
An agent prepares a Jira ticket. A human approves, edits the description, or rejects ticket creation entirely.

Control Flow Nodes Comparison

When to Use Each Node

Choose Router Node when you:
  • Need multiple named routes based on explicit conditions
  • Have condition logic you can express in Jinja2-like templates
  • Want fast, deterministic routing without LLM overhead
  • Know all possible paths and conditions upfront
  • Need to match keywords, compare values, or check status
  • Need binary or multi-branch conditional logic with if-else routing
  • Want to create loops by routing back to previous nodes
Example: Route tickets by priority level (critical/high/medium/low), approval status (approved/pending/rejected), validation branching (valid → ProcessPath, invalid → ErrorPath), or iterative processing with loop control.
Choose Decision Node when you:
  • Need LLM intelligence for routing decisions
  • Routing logic is complex, nuanced, or context-dependent
  • Want natural language decision criteria instead of templates
  • Require semantic understanding of user input or content
  • Template conditions are too rigid or difficult to express
  • Need to analyze multiple input variables simultaneously
  • Routing depends on understanding intent, sentiment, or meaning
Example: Customer support routing (technical/billing/general inquiries), sentiment analysis (positive/negative/neutral routing), intent classification, context-aware content moderation, or multi-factor decision making based on conversation history.
Choose HITL Node when you need:
  • A human to approve, reject, or edit pipeline output before it is acted upon
  • A compliance checkpoint before an irreversible operation (database write, external API call, email send)
  • Inline human correction of AI-generated content without restarting the pipeline
  • An explicit audit trail of human decisions in an automated workflow

Deprecated Control Flow Nodes

The following control flow nodes are deprecated and will be removed in a future release. Please migrate to the recommended alternatives:
The Condition node is deprecated and will be removed in an upcoming release.Migration: Use the Router node for expression-based routing or the Decision node for AI-powered routing decisions.Migration Guide: Condition Node Migration