Forjinn Docs

Development Platform

Documentation v2.0
Made with
by Forjinn

Loop

Learn about loop and how to implement it effectively.

3 min read
🆕Recently updated
Last updated: 12/9/2025

Loop (Agentflow Node)

The Loop node in InnoSynth-Forjinn's Agentflow provides a mechanism to create iterative workflows by looping back to a previous node in the canvas. This is particularly useful for implementing retry mechanisms, continuous monitoring, or conversational loops where the AI needs to re-evaluate or re-engage based on certain conditions.

Purpose

The Loop node is designed for:

  • Retry Mechanisms: Re-attempting a failed operation a specified number of times.
  • Conversational Loops: Guiding a user through a series of questions or steps until a condition is met.
  • Continuous Processing: Repeatedly executing a segment of the workflow.
  • Error Handling: Looping back to a previous state if an error occurs, allowing for recovery attempts.

Appearance on Canvas

(Image: Placeholder for the Loop node icon/appearance on the canvas)

Configuration Parameters

The Loop node requires you to specify the target node to loop back to and a maximum iteration count.

1. Loop Back To (Required)

  • Label: Loop Back To
  • Type: asyncOptions (loads previous nodes)
  • Description: Select the specific node in your current workflow that the execution should loop back to. This allows you to define the starting point of your iterative process.
  • Hint: Make sure to have memory enabled in the LLM/agent node to retain the chat history if you are looping in a conversational context.

2. Max Loop Count (Required)

  • Label: Max Loop Count
  • Type: number
  • Default: 5
  • Description: The maximum number of times the loop will execute. This is a critical safeguard to prevent infinite loops and ensure your workflow eventually terminates.

Inputs & Outputs

  • Input: The Loop node typically receives a trigger from a preceding node, indicating that the loop condition has been met or a retry is needed.
  • Output: This node does not have a visible output port on the canvas, as its primary function is to redirect the workflow's execution flow back to a previous node. The hideOutput property is set to true.

How it Works During Execution

When the workflow reaches a Loop node:

  1. It identifies the Loop Back To target node.
  2. It checks the current loop count for the specific execution path.
  3. If the Max Loop Count has not been reached, the workflow's execution pointer is reset to the Loop Back To node, and the process within the loop restarts.
  4. If the Max Loop Count has been reached, the loop terminates, and the workflow typically proceeds to any nodes connected after the loop block (if any, though often a loop is the end of a specific branch).

Example Usage: Retrying an API Call

Consider a scenario where an API call might occasionally fail, and you want to retry it a few times before giving up.

  1. Connect an HTTP node (making an API call) to a condition node.
  2. Configure condition: Check if the HTTP node's output indicates an error (e.g., {{http.status}} is larger equal 400).
  3. Connect condition Output (Error Path): Connect the output for the error condition to a Loop node.
  4. Configure Loop:
    • Loop Back To: Select the HTTP node.
    • Max Loop Count: 3
  5. Connect condition Output (Success Path): Connect the output for the success condition to a Chat Output node.
  6. Connect Loop Output (Implicit Fallthrough): If the loop maxes out, the workflow would implicitly continue to a "Handle Error" node (not directly connected to the Loop node, but as a fallback in the overall flow design).

This setup will retry the HTTP call up to 3 times if it fails, providing resilience to your workflow.