> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ovalbee.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ovalbee.com/_mcp/server.

# AI gate

> An agent reads the reports of the nodes in its flow, does what your prompt asks, writes a summary report and decides whether the flow continues.

## Overview

An agent that reads the reports of the other nodes in its flow, does what you ask in plain words, writes a summary report and decides whether the flow continues. You write the **Prompt**, for example "Summarise how the new model performs and name the classes with the weakest AP", and, if the flow should only go on when something holds, a **Continue only if** condition such as "mAP 50:95 is at least 0.4 and no class has AP below 0.3". The instance's language model works step by step, with the same read tools the OvalBee agent uses: it looks at the flow's nodes and how they connect, at what each run did and produced, and at the reports and their data files. Then it answers the prompt and decides whether the flow continues. A reason it gives can point at a data file of a report, and the summary report shows that file as the same chart or table the source report draws.

You don't connect reports to it: it finds them in its flow by itself. Put it after the nodes whose reports it should judge, such as [Evaluate object detection](/node-library/nodes/evaluate-evaluate-object-detection), [Compare object detectors](/node-library/nodes/evaluate-compare-object-detectors), [Annotation quality](/node-library/nodes/dataset-ops-annotation-quality) or [Dataset insights](/node-library/nodes/dataset-ops-dataset-insights), and before the steps that should only run when they look right, such as an export or a model upload. The badge on the node shows the decision, and the answer can go straight into the body of a [Send email](/node-library/nodes/notifications-send-email) node.

```mermaid
flowchart LR
  n1["Train YOLO"] --> n2["Evaluate object detection"] --> n3["AI gate"] --> n4["Export YOLO"]
```

## Prerequisites

| Requirement           | What you need                                                                                                                                                                                                                                                                                                        |
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Reports**           | At least one other node in the flow that has written a report, such as an evaluation, a comparison or a dataset analysis.                                                                                                                                                                                            |
| **Workspace credits** | Every step of the agent is one call to the language model of the OvalBee instance, charged to the workspace's credits. The node's **Max agent steps** (40 unless you change it, at most 100) caps a run. On a self-hosted instance the admin must set an LLM token in the instance settings, and nothing is charged. |

## How it works

Hands your prompt and condition to the agent, with the flow and the place of AI gate in it.

Runs the agent. At each step the model calls one or more read tools: the flow's nodes and connections, the state and history of its runs, a run's log, a report or one of its data files. It sees the results at the next step, and goes on until it finishes with its answer, its reasons, the data it found missing and whether the flow continues, or until **Max agent steps** runs out.

Decides as the agent did. Running out of steps stops the flow. The finish has a fixed form, which a model that supports strict tool use always keeps; a model that doesn't may send a finish that breaks it, and then the task fails with "the agent's answer does not match the contract" and what was wrong.

Writes the summary report and sets the outputs. On **Stop**, the nodes connected after AI gate don't start.

## FAQ

#### Which reports does it read?

Any report a node of the same flow produced, whether or not it is connected to AI gate. The agent sees the flow's connections and the time of every run, so it can tell the reports of the nodes before AI gate, which come from the run that started it, from those of a node after it or in another branch, which are from an earlier run of that node and possibly an old one. An answer that relies on such a report should say so. The agent decides which reports and files are worth reading for your prompt; it doesn't have to read them all. It reads only this flow, not the other flows of the workspace.

#### What happens on Stop?

The nodes connected after AI gate don't start, so an export or a model upload behind it never runs. Other branches of the same run keep going, and results already produced stay as they are. The decision, the answer and the summary report are written either way.

#### What if the reports don't hold what the prompt needs?

The agent is told to stop the flow when it couldn't find what the prompt or the condition needs, for example a metric no report contains or a file that couldn't be read, and to list it. The decision is the agent's, so write in the prompt or the condition how you want such a case treated if it matters. A run that uses all its steps without finishing always stops the flow. The missing data is listed in the summary report and in the answer.

#### What is sent to the language model?

Your prompt and condition, and what the agent reads: the flow document, the state and outputs of its runs, run logs it opens, report sections and the numbers in them, their findings, and their data files, with large JSON trimmed and tables one page at a time. Images are never sent. The request goes through the OvalBee API to the model the instance is configured with.

#### How much does a run cost?

One model call per step, up to **Max agent steps**, each charged to the workspace's credits. A step costs more the more the agent has read, because everything read so far goes with it; with an Anthropic model most of that is read from the provider's prompt cache. The summary report shows the number of steps, the tokens and the credits of the run.

#### Why did the run fail without a decision?

The task log names the reason. The agent run failed: the instance has no LLM token configured (its admin must add one in the instance settings), the workspace has no credits left for the month, or the model returned an error. Or the agent's answer didn't match the form AI gate expects, which happens only with a model that doesn't support strict tool use: the instance's admin can pick one that does.

## Inputs

**`Prompt`** `text` — required

What the agent should do with the reports of the flow's nodes, in plain words. It reads their text and data files, never their images. Key: `PROMPT`.

---

**`Continue only if`** `text`

A condition the flow continues only if it holds, in plain words. Leave empty to continue whenever the agent found what the prompt needs. The flow also stops when the agent runs out of steps. Key: `CONTINUE_ONLY_IF`.

---

**`Max agent steps`** `integer` — required, default: 40

The most model calls the agent may make, each charged to the workspace's credits. When they run out before it answers, the flow stops. Minimum: `1`. Maximum: `100`. Step: `1`. Key: `MAX_STEPS`.

---

## Outputs

**`Decision`** `string`

Continue or Stop. Shown on the node as a badge. Key: `VERDICT`.

---

**`Answer`** `string`

The agent's answer to the prompt as plain text, then the decision, its reasons and any missing data, ready to send in an email. Key: `ANSWER`.

---

**`Report`** `report`

Asset ID of the summary report, with the decision, the answer, the reasons with the charts they rest on, any missing data, and the steps the agent took. Shown as an artifact. Key: `REPORT_ID`.

---

## Report

The summary report opens with the decision, **Continue** or **Stop**, and why in one line, followed by your prompt and condition. Next comes the agent's answer to the prompt. Each reason is followed by the chart or table it rests on, copied with its data from the source report, so you see the numbers themselves rather than the model's account of them. A click on the copied chart opens nothing, as the files a click opens in the source report are not copied. A chart that can't be copied as it is, for example one drawn per data scope, isn't copied, and the reason names its file and report instead. A Missing data section lists what the agent couldn't find. The Steps section lists every tool call the agent made, in order, with whether it worked. The last section names the model, the number of steps against **Max agent steps**, the tokens used (and how many of them came from the provider's cache) and the credits charged.

## JSON config

Machine-readable node interface for automation and advanced usage.

#### Show JSON

```json
{
  "name": "AI gate",
  "description": "An agent reads the reports of the nodes in its flow, does what your prompt asks, writes a summary report and decides whether the flow continues.",
  "category": "Flow control",
  "namespace": null,
  "templateKey": "flow_control/ai_gate",
  "version": "v1",
  "inputs": [
    {
      "key": "PROMPT",
      "label": "Prompt",
      "type": "text",
      "description": "What the agent should do with the reports of the flow's nodes, in plain words. It reads their text and data files, never their images.",
      "required": true,
      "default": "Check the latest evaluation report: summarise how the model performs overall and name the classes with the weakest AP.",
      "visibleWhen": null
    },
    {
      "key": "CONTINUE_ONLY_IF",
      "label": "Continue only if",
      "type": "text",
      "description": "A condition the flow continues only if it holds, in plain words. Leave empty to continue whenever the agent found what the prompt needs. The flow also stops when the agent runs out of steps.",
      "required": false,
      "default": null,
      "visibleWhen": null
    },
    {
      "key": "MAX_STEPS",
      "label": "Max agent steps",
      "type": "number",
      "description": "The most model calls the agent may make, each charged to the workspace's credits. When they run out before it answers, the flow stops.",
      "required": true,
      "default": 40,
      "visibleWhen": null,
      "options": {
        "type": "integer",
        "min": 1,
        "max": 100,
        "step": 1,
        "slider": false
      }
    }
  ],
  "outputs": [
    {
      "key": "VERDICT",
      "label": "Decision",
      "type": "string",
      "description": "Continue or Stop.",
      "artifact": false,
      "badge": true,
      "badgeOpens": null,
      "hidden": false
    },
    {
      "key": "ANSWER",
      "label": "Answer",
      "type": "string",
      "description": "The agent's answer to the prompt as plain text, then the decision, its reasons and any missing data, ready to send in an email.",
      "artifact": false,
      "badge": false,
      "badgeOpens": null,
      "hidden": false
    },
    {
      "key": "REPORT_ID",
      "label": "Report",
      "type": "report",
      "description": "Asset ID of the summary report, with the decision, the answer, the reasons with the charts they rest on, any missing data, and the steps the agent took.",
      "artifact": true,
      "badge": false,
      "badgeOpens": null,
      "hidden": false
    }
  ],
  "widgets": {
    "widget": {
      "id": "report-preview",
      "settings": {
        "reportAsset": {
          "type": "variable",
          "value": "self.outputs.REPORT_ID"
        },
        "name": {
          "type": "input",
          "value": "Open verdict"
        }
      }
    }
  }
}
```