# Loop Gate – Agentic Loop Continuation Decision

> Loop Gate – Agentic Loop Continuation Decision is a paid API for AI agents from agent402.tools, paid per call via x402, $0.001/call, status unknown (last checked 2026-10-30).

Decides whether an agentic loop should continue iterating, stop, or escalate, based on goal progress, budget, iteration count, history, and constraints.

## Facts

- Endpoint: POST https://agent402.tools/api/loop-gate?utm_source=zero.xyz
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-30
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/loop-gate-agentic-loop-continuation-decision-dc040121
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_ADIihmzpbFdGuXMHqWuFr

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability loop-gate-agentic-loop-continuation-decision-dc040121 -d '<json body>'
```

Example prompt: My agent loop is on iteration 3 trying to 'write a complete market analysis report', the last output was a draft with missing competitor data, I've spent $0.04 of a $0.10 budget, and I have a constraint that the report must cite at least 5 sources — should it keep running or stop?

## When to prefer this

Choose this endpoint when you need a neutral, stateless arbitration layer to decide loop continuation in an autonomous agent workflow — especially when you want transparent reasoning with per-check flags (stuck, repeating, constraintBreached) rather than implementing custom termination logic yourself. Ideal for multi-iteration agents that need budget guardrails, goal-completion detection, and escalation paths built in.

## Known failure modes

- Missing required fields (goal or iteration) returns a 400 validation error
- Goal string too vague for meaningful goalMet evaluation, resulting in low-confidence decisions
- History array exceeding 20 items may be truncated or rejected
- Budget values inconsistent (spentUsd > maxUsd on first iteration) may yield immediate budgetExceeded=true
- Payment failure (x402 protocol) returns 402 Payment Required before processing

## How this service works

Should the loop run another iteration? Send the goal, the iteration that just finished (lastOutput, iteration), and optionally maxIterations, a budget { spentUsd, maxUsd }, the history of earlier iterations (up to 20 of { iteration, summary }, oldest first) and constraints; get back decision (continue, stop or escalate), reason, confidence (0 to 1), the checks that produced it (goalMet, budgetExceeded, iterationsExhausted, repeating, stuck, constraintBreached) and nextStep (iterate.

## Output

Returns a JSON object with: decision (one of 'continue', 'stop', or 'escalate'), a human-readable reason string, a confidence score between 0 and 1, a nextStep suggestion, and a checks object containing boolean flags for goalMet, budgetExceeded, iterationsExhausted, repeating, stuck, and constraintBreached.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "goal": {
   "type": "string"
  },
  "budget": {
   "type": "object",
   "properties": {
    "maxUsd": {
     "type": "number",
     "exclusiveMinimum": 0
    },
    "spentUsd": {
     "type": "number",
     "minimum": 0
    }
   }
  },
  "history": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "iteration",
     "summary"
    ],
    "properties": {
     "summary": {
      "type": "string"
     },
     "iteration": {
      "type": "integer",
      "minimum": 1
     }
    }
   }
  },
  "iteration": {
   "type": "integer",
   "minimum": 1
  },
  "lastOutput": {
   "type": [
    "string",
    "object"
   ]
  },
  "constraints": {
   "type": "array",
   "items": {
    "type": "string"
   }
  },
  "maxIterations": {
   "type": "integer",
   "minimum": 1
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/loop-gate-agentic-loop-continuation-decision-dc040121/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent402.tools](https://www.zero.xyz/host/agent402.tools/llms.txt)
