# Sequential Agent

The **Sequential Agent** in THub is a component within the AgentFlow V1 architecture designed to execute a series of tasks in a predetermined order. This setup is particularly useful for workflows that require a structured sequence of operations, such as data collection, processing, and response generation.

#### 1) **Agent Node**

The **Agent Node** serves as the central decision-making component within a workflow. It leverages a Large Language Model (LLM) to process inputs, access tools, and retrieve information from knowledge bases to generate context-aware responses.

**Key Features:**

* **Tool Integration**: Configure which tools the agent can utilize.
* **Knowledge Access**: Connect to document stores or vector databases for information retrieval.
* **Memory Management**: Enable or disable memory to consider past interactions.
* **Flow State Updates**: Modify the workflow's runtime state (`$flow.state`) during execution.

**Inputs**: Data from prior nodes or initial triggers.

**Outputs**: Agent-generated responses, either as plain text or structured JSON.

<figure><img src="https://1720595571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxWXmt1Z68dgle5JORrEw%2Fuploads%2F64mFS8Q96veR9aiXGkqj%2Fimage.png?alt=media&#x26;token=1250a958-b798-49d6-b982-e40cccce5999" alt=""><figcaption></figcaption></figure>

#### **2)Condition Node**

The **Condition Node** introduces deterministic branching logic, allowing the workflow to diverge based on specified conditions.

**Key Features:**

* **Conditional Evaluation**: Assess input values using logical operators (e.g., equals, contains).
* **Branching Paths**: Direct the workflow along different routes based on evaluation results.

**Inputs**: Data to be evaluated.

**Outputs**: Branches corresponding to condition outcomes (e.g., true or false).

<figure><img src="https://1720595571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxWXmt1Z68dgle5JORrEw%2Fuploads%2FoNaIhUILdVsR0EjsqTFJ%2Fimage.png?alt=media&#x26;token=88f83d4a-00a7-4037-b608-4b9b1f93b603" alt=""><figcaption></figcaption></figure>

#### **3)Condition  Agent**

The Condition agent  is an agent that uses a large language model (LLM) to decide which actions to take based on specific conditions or criteria. This means the agent's behavior isn't solely determined by a predefined workflow, but it uses its reasoning capabilities to select the most appropriate course of action based on the current state and input.

<figure><img src="https://1720595571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxWXmt1Z68dgle5JORrEw%2Fuploads%2FRrYox6PjVU1IlqCpuZcy%2Fimage.png?alt=media&#x26;token=7caf00c2-9939-4688-a03b-a9e7d325e350" alt=""><figcaption></figcaption></figure>

#### **4)Custom JS Function Node**

The **Custom JS Function Node** allows the execution of bespoke JavaScript code within the workflow, enabling complex data transformations or integrations.

**Key Features:**

* **Custom Logic**: Implement specific operations not covered by standard nodes.
* **Access to Flow Context**: Utilize variables like `$flow.state`, `$flow.input`, and custom-defined variables.
* **Flow State Updates**: Modify the workflow's runtime state based on function outcomes.

**Inputs**: Defined input variables and access to flow context.

**Outputs**: String value returned by the executed JavaScript function.

<figure><img src="https://1720595571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxWXmt1Z68dgle5JORrEw%2Fuploads%2FoqOZxlm4rWo21ngQzag8%2Fimage.png?alt=media&#x26;token=5148aff6-8909-4373-b43a-30cdd80d9e71" alt=""><figcaption></figcaption></figure>

#### **5)END Node**

The **END Node** signifies the termination point of a workflow or a specific branch within it.

**Key Features:**

* **Final Output**: Deliver a concluding message to the user, which can be static or dynamically generated.
* **Workflow Termination**: No further nodes are processed beyond this point.

**Inputs**: Message content from previous nodes or flow state.

**Outputs**: None; this node concludes the execution path.

<figure><img src="https://1720595571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxWXmt1Z68dgle5JORrEw%2Fuploads%2Fxp3wcg9F4u5OUcfYE5nn%2Fimage.png?alt=media&#x26;token=71e54a31-c9cf-4e9b-a2cb-1ce10c348bef" alt="" width="158"><figcaption></figcaption></figure>

#### 6) **Execute Flow Node**

The **Execute Flow Node** enables the invocation of another complete THub Chatflow or AgentFlow from within the current workflow, promoting modular design.

**Key Features:**

* **Sub-Workflow Execution**: Trigger separate, pre-existing workflows.
* **Input Passing**: Provide initial inputs to the invoked workflow.
* **Flow State Updates**: Incorporate outputs from the executed sub-flow into the current workflow's state.

**Inputs**: Execution signal and input data for the sub-flow.

**Outputs**: Results returned by the executed sub-flow.

<figure><img src="https://1720595571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxWXmt1Z68dgle5JORrEw%2Fuploads%2FNqzqL1AXnqRO8NjgiIEN%2Fimage.png?alt=media&#x26;token=0a311c8a-a7a4-4c0a-b449-0877af50c2ef" alt="" width="161"><figcaption></figcaption></figure>

#### 7)**LLM Node**

The **LLM Node** provides direct access to a configured Large Language Model for executing AI tasks, such as data extraction or content generation.

**Key Features:**

* **Structured Output**: Configure the LLM to return responses in a specific JSON schema.
* **Flow State Updates**: Store LLM outputs in the workflow's runtime state for downstream use.

**Inputs**: Data from the workflow's initial trigger or preceding nodes.

**Outputs**: LLM-generated responses, either as plain text or structured data.

<figure><img src="https://1720595571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxWXmt1Z68dgle5JORrEw%2Fuploads%2FC2PqdOGLNLCpGEHSSJLz%2Fimage.png?alt=media&#x26;token=a6925b93-0228-425b-9137-503566e0650c" alt="" width="161"><figcaption></figcaption></figure>

#### **8)Loop Node**

The **Loop Node** introduces controlled cycles within the workflow, enabling iterative processes where a sequence of nodes is executed multiple times based on defined conditions.

**Key Features:**

* **Iteration Control**: Define the maximum number of loop iterations to prevent infinite cycles.
* **Loop Back Target**: Specify the node to which the workflow should return after each iteration.

**Inputs**: Execution signal to activate the loop.

**Outputs**: Redirects execution flow back to the specified node.

<figure><img src="https://1720595571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxWXmt1Z68dgle5JORrEw%2Fuploads%2FN52mdmEk4qYNlTopAyHl%2Fimage.png?alt=media&#x26;token=a31ea6c5-032f-4e52-abd2-2a49a8bc8820" alt="" width="158"><figcaption></figcaption></figure>

#### **9)Start Node**

The **Start Node** is the designated entry point for initiating any AgentFlow V2 workflow execution.

**Key Features:**

* **Input Configuration**: Determine how the workflow is triggered, either by chat input or a submitted form.
* **Flow State Initialization**: Define the initial key-value pairs for the workflow's runtime state.
* **Memory Settings**: Configure whether to consider past messages from the conversation thread.

**Inputs**: Initial data that triggers the workflow.

**Outputs**: Passes along the initial input data and the initialized Flow State to the first operational node.

<figure><img src="https://1720595571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxWXmt1Z68dgle5JORrEw%2Fuploads%2Faa5wV6G7SWpNr5OEAJre%2Fimage.png?alt=media&#x26;token=7db6e316-dade-4f04-aae6-d626a2df6e1f" alt="" width="236"><figcaption></figcaption></figure>

#### 10) State Node

The **State Node** provides a mechanism for storing and managing intermediate data within the workflow, allowing information to be shared across different nodes.

**Key Features:**

• **Data Storage**: Stores intermediate values during workflow execution.\
• **State Persistence:** Maintains data across multiple steps in the flow.\
• **Flexible Usage:** Can store different types of data as required.\
• **Workflow Integration:** Enables smooth data sharing between nodes.

**Inputs:** Necessary data or values to be stored, usually coming from previous node outputs.

**Outputs:** Stored state data that can be accessed and used by subsequent nodes in the workflow.

<figure><img src="https://1720595571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxWXmt1Z68dgle5JORrEw%2Fuploads%2FrKaKX4PiWCReySxXhyeX%2Fimage.png?alt=media&#x26;token=e391863f-575f-4226-a48f-3d4b37bdb124" alt=""><figcaption></figcaption></figure>

#### 11) **Tool Node**

The **Tool Node** provides a mechanism for directly and deterministically executing a specific, pre-defined Flowise Tool within the workflow sequence.

**Key Features:**

* **Deterministic Execution**: Executes the selected tool without involving LLM reasoning for tool selection.
* **Input Argument Mapping**: Define how data from your workflow is supplied to the selected tool.
* **Flow State Updates**: Store the tool's output in the workflow's runtime state for use in subsequent nodes.

**Inputs**: Necessary data for the tool's arguments, sourced from previous node outputs or flow state.

**Outputs**: Raw output generated by the executed tool.

<figure><img src="https://1720595571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxWXmt1Z68dgle5JORrEw%2Fuploads%2F5SUJSX2q23UzKyMrTt92%2Fimage.png?alt=media&#x26;token=899c80d2-5c03-4a2d-9cba-f172ee3483bb" alt="" width="225"><figcaption></figcaption></figure>
