{"uid":"cap_ADIihmzpbFdGuXMHqWuFr","slug":"loop-gate-agentic-loop-continuation-decision-dc040121","name":"Loop Gate – Agentic Loop Continuation Decision","description":"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.","url":"https://agent402.tools/api/loop-gate?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"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}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_E-I0lrv5-oLsXSyVk6wHR","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Decides whether an agentic loop should continue iterating, stop, or escalate, based on goal progress, budget, iteration count, history, and constraints.","exampleAgentPrompt":"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?","exampleUseCases":[{"title":"Budget-aware research agent loop","prompt":"I'm running a research agent that's trying to 'compile a list of 20 venture-backed AI startups from 2024'. It just finished iteration 5 out of a max of 10, found 14 startups so far, and has spent $0.07 of my $0.15 budget. Should it keep going or stop?"},{"title":"Detecting a stuck code-generation loop","prompt":"My coding agent is on iteration 8 trying to 'fix a type error in the TypeScript codebase' and has produced almost identical output for the last 3 iterations. I have a constraint that it must not modify test files. Check if it's stuck and tell me whether to continue, stop, or escalate."},{"title":"Constraint-checking before final loop iteration","prompt":"My data-cleaning agent just finished iteration 4 out of 5 working toward 'produce a fully deduplicated customer CSV with no nulls in required fields'. The last output still has 3 null email addresses. My constraints are no deletions of records and max $0.05 spend — $0.038 used so far. Should it run one more iteration?"}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-30T00:36:01.148Z","isFirstParty":false,"canonicalSlug":"loop-gate-agentic-loop-continuation-decision-dc040121"}