Logic ===== Logic components control branching, looping, conditional evaluation, code execution, and output validation. ---- .. _component-ref-if-else: If-Else ------- Branches the flow based on a boolean condition evaluated against an input value. **Use in a flow** 1. Add an **If-Else** node to the canvas. 2. Enter **Text Input** and **Match Text**. 3. Choose an **Operator** to compare them. 4. Connect **Message** (the payload to pass through the matching branch). 5. Wire **True** or **False** outputs to different downstream paths. .. code-block:: text Input ──► If-Else ──► True branch ──► Agent A └──► False branch ──► Agent B Only the matching branch receives the message; the other branch is stopped. **Parameters** .. list-table:: :widths: 30 10 10 50 :header-rows: 1 * - Parameter - Default - Hidden - Description * - Text Input - — - No - The value to evaluate. Required. * - Match Text - — - No - The text to compare against. Required. * - Operator - equals - No - Comparison: ``equals``, ``not equals``, ``contains``, ``starts with``, ``ends with``, or ``regex``. * - Case Sensitive - false - No - Case-sensitive comparison (not used for ``regex``). * - Message - — - No - Message passed through the active branch. * - Max Iterations - 10 - Yes - Maximum loop iterations before forcing a route. * - Default Route - false_result - Yes - Route taken when max iterations is reached. **Outputs** .. list-table:: :widths: 25 75 :header-rows: 1 * - Output - Description * - True - Fires when the condition is met. Passes **Message** downstream. * - False - Fires when the condition is not met. Passes **Message** downstream. **Limitations** - **Text comparison** — Compares string values; both **Text Input** and **Match Text** are required. - **Regex** — Invalid regex patterns evaluate to false. - **Single branch** — Only one output runs per execution; the other is stopped. ---- .. _component-ref-condition-legacy: Condition *(Legacy)* -------------------- Evaluates a conditional expression and routes to one of multiple output paths based on the result. **Use in a flow** 1. Add a **Condition** node to the canvas (legacy component). 2. Connect **Data Input** from an upstream component. 3. Enter **Key Name** — the field in the Data object to evaluate. 4. Choose an **Operator** and **Match Text** (if applicable). 5. Wire **True Output** or **False Output** downstream. .. code-block:: text Data source ──► Condition ──► True Output ──► processing └──► False Output ──► alternate path **Parameters** .. list-table:: :widths: 30 10 60 :header-rows: 1 * - Parameter - Default - Description * - Data Input - — - One or more Data objects to evaluate. * - Key Name - — - Key in the Data object to check. * - Operator - equals - ``equals``, ``not equals``, ``contains``, ``starts with``, ``ends with``, or ``boolean validator``. * - Match Text - — - Value to compare against. Hidden when **Operator** is ``boolean validator``. When **Operator** is ``boolean validator``, the key value is treated as a boolean (``true``, ``1``, ``yes``, ``y``, ``on`` are truthy). **Match Text** is not used. **Outputs** .. list-table:: :widths: 25 75 :header-rows: 1 * - Output - Description * - True Output - Fires when the condition is met. Returns matching Data object(s). * - False Output - Fires when the condition is not met. Returns non-matching Data object(s). **Limitations** - **Legacy** — Prefer :ref:`If-Else ` for new flows unless you need Data-key routing. - **Data input** — Input must be Data objects with the specified key. - **Missing key** — Returns an error if **Key Name** is not found in the Data object. ---- .. _component-ref-code-execution: Code Execution -------------- Executes a Python snippet and returns the result. Use it for custom logic that cannot be expressed with other components. **Use in a flow** 1. Add a **Code Execution** node to the canvas. 2. Select **Language** (``python`` or ``node.js``). 3. Write **Source Code**. 4. Optionally add **Dependencies** (Python packages). 5. Connect **Result** downstream. .. code-block:: text Input ──► Code Execution ──► Data Operations / Agent Code runs in an isolated execution service. The stdout, stderr, exit code, and execution time are returned. **Parameters** .. list-table:: :widths: 30 10 10 50 :header-rows: 1 * - Parameter - Default - Hidden - Description * - Language - python - No - ``python`` or ``node.js``. Required. * - Source Code - — - No - Code to execute. Accepts Message input. Required. * - Dependencies - — - Yes - Comma-separated pip packages to install before execution (e.g., ``requests,pandas``). **Outputs** .. list-table:: :widths: 25 75 :header-rows: 1 * - Output - Description * - Result - Data object with ``result`` (stdout), ``error`` (stderr), ``exit_code``, ``status``, and ``execution_time_ms``. **Limitations** - **Isolated runtime** — Code runs via the Code Execution Service, not in-process. - **Python dependencies** — Only pip packages listed in **Dependencies** are installed. - **Errors** — Execution failures return an error field in the result instead of raising in the flow. ---- .. _component-ref-guardrail: Guardrail --------- Applies a configured guardrail policy to data passing through this point. Content that violates the policy is routed to the fail path. **Use in a flow** 1. Add a **Guardrail** node in the path you want to validate. 2. Select one or more **Selected Guardrails** (format: ``guardrail_name#INHOUSE`` or ``guardrail_name#BEDROCK``). 3. Connect **Input Message** from upstream. 4. Wire **Pass** and **Fail** outputs to different downstream paths. .. code-block:: text Input ──► Guardrail ──► Pass ──► Agent └──► Fail ──► blocked response / Output **Parameters** .. list-table:: :widths: 30 10 10 50 :header-rows: 1 * - Parameter - Default - Hidden - Description * - Selected Guardrails - — - No - One or more guardrails to execute. Required. * - Input Message - — - No - Message to validate. Required. * - Apply To - INPUT - No - Validate ``INPUT`` (user message) or ``OUTPUT`` (generated response). Required. * - Model Provider - — - No - Required for INHOUSE guardrails. * - Model ID - — - No - Model for INHOUSE guardrail execution. * - Region Name - — - No - Region for the selected model. * - Context - — - No - Additional context for guardrail evaluation. * - Generated Output - — - No - Generated output to validate (for OUTPUT validation). * - Enable Retry - false - Yes - Retry failed guardrail API requests. * - Max Retries - 3 - Yes - Maximum retry attempts. * - Save Output as Variable - false - Yes - Store output as a flow variable. * - Variable Name - — - No - Name for the flow state variable. **Outputs** .. list-table:: :widths: 25 75 :header-rows: 1 * - Output - Description * - Pass - Fires when all guardrails pass. Returns the validated message. * - Fail - Fires when content is blocked. Returns the blocked message. **Limitations** - **Guardrails required** — At least one guardrail must be selected. - **Dual routing** — Only one branch runs per execution. - **Large content** — Long text and PDFs are chunked before evaluation. - **Images** — PNG and JPEG attachments are supported in evaluation. ---- .. _component-ref-loop: Loop ---- Iterates over a list of items and executes a downstream path for each item. **Use in a flow** 1. Add a **Loop** node to the canvas. 2. Connect a list of **Data** objects (or a single Data object). 3. Wire **Item** output into the processing branch. 4. Connect the loop-back edge from the end of the branch back to **Loop**. 5. Wire **Done** output for aggregated results after all items are processed. .. code-block:: text Data source ──► Loop (Item) ──► processing ──► (loop back) └── (Done) ──► Output **Parameters** .. list-table:: :widths: 30 70 :header-rows: 1 * - Parameter - Description * - Data - Initial list of Data objects to iterate over, or a single Data object. Required. **Outputs** .. list-table:: :widths: 25 75 :header-rows: 1 * - Output - Description * - Item - One Data object per iteration. Connect downstream processing here. Supports loop edges. * - Done - Fires when all items are processed. Returns aggregated results from loop inputs. **Limitations** - **Data only** — Input must be Data objects or a list of Data objects. - **Loop wiring** — The processing branch must connect back to the Loop node for iteration. - **Aggregation** — **Done** collects outputs wired back via the loop input. ---- .. _component-ref-run-flow: Run Flow *(Beta)* ----------------- Executes another flow by ID and returns its output. **Use in a flow** 1. Add a **Run Flow (Beta)** node to the canvas. 2. Select **Flow Name** from the dropdown (loads available flows). 3. Fill in any dynamic input fields exposed by the selected flow. 4. Connect **Flow Message Output** downstream. .. code-block:: text Input ──► Run Flow ──► Output / Agent Agent ──► Run Flow (as tool) When a flow is selected, the component exposes that flow's input fields as tweakable parameters. In tool mode, the selected flow becomes a callable tool. **Parameters** .. list-table:: :widths: 30 10 60 :header-rows: 1 * - Parameter - Hidden - Description * - Flow Name - No - The flow to execute. Selecting a flow adds its input fields dynamically. * - Session ID - Yes - Session ID for the sub-flow run. * - Dynamic flow inputs - No - Input fields from the selected flow (named ``{node_id}~{field_name}``). Appear after flow selection. **Outputs** .. list-table:: :widths: 25 75 :header-rows: 1 * - Output - Description * - Flow Message Output - Primary message output from the executed flow. * - Flow Data Output - Data output from the executed flow (hidden by default). * - Flow Dataframe Output - DataFrame output from the executed flow (hidden by default). **Limitations** - **Beta** — Behavior may change. - **Flow selection required** — A flow must be selected before execution. - **Tool mode** — Select a flow to enable using this component as a tool in an Agent. ---- .. _component-ref-confidence-score: Confidence Score Component -------------------------- Evaluates a confidence score and branches on whether it exceeds a configured threshold. **Use in a flow** 1. Add a **Confidence Score Component** node after an Agent or LLM step. 2. Select **Strategy** (currently **Contextual Grounding**). 3. Choose a **Confidence Scoring Rule** (Bedrock guardrail with contextual grounding enabled). 4. Wire **Context**, **Generated Output**, and **Input Message**. 5. Connect **Above Threshold** and **Below Threshold** to different paths. .. code-block:: text Agent ──► Confidence Score Component ──► Above Threshold ──► Output └──► Below Threshold ──► fallback **Parameters** .. list-table:: :widths: 30 10 10 50 :header-rows: 1 * - Parameter - Default - Hidden - Description * - Strategy - — - No - Scoring strategy. Currently **Contextual Grounding**. Required. * - Confidence Scoring Rule - — - No - Bedrock guardrail rule to execute. Required. * - Confidence Threshold - — - No - Override threshold (0.0–1.0). Leave empty to use the guardrail default. * - Blocked Message - — - No - Message returned when score is below threshold. * - Context - — - No - Grounding source context for scoring. Required. * - Generated Output - — - No - Agent or LLM output to evaluate. Required. * - Input Message - — - No - Original user message (preserves message properties). Required. * - Output Field - confidence score - No - ``confidence score`` or ``message`` as the routed output content. Required. * - Model Provider - — - Yes - Required when a Bedrock scoring rule is selected. * - Model ID - — - Yes - Model for Bedrock guardrail execution. * - Region Name - — - Yes - Region for the selected model. **Outputs** .. list-table:: :widths: 25 75 :header-rows: 1 * - Output - Description * - Above Threshold - Fires when the confidence score meets or exceeds the threshold. * - Below Threshold - Fires when the score is below the threshold. Returns blocked message or score based on **Output Field**. **Limitations** - **Bedrock guardrail required** — Scoring rule must be a Bedrock guardrail with contextual grounding policy enabled. - **Context and output required** — Both **Context** and **Generated Output** are needed for grounding evaluation. - **Score calculation** — When both GROUNDING and RELEVANCE filters are present, the minimum score is used.