Skip to content

AI agent loop with no real step limit

Gapmedium severity · reads .ts .tsx .js .jsx .mjs .cjs .pyBeta

Each step is another paid model call and maybe another tool run. With no limit, one request, or one prompt-injected document, can keep the agent going until something times out. When Lintsure finds this, it marks it as a Gap: the code itself shows the problem.

What it looks like

A line Lintsure flags in its own test app:

// app/api/chat/route.ts
const result = streamText({ model: "openai/gpt-5", system, messages, stopWhen: isLoopFinished(), maxOutputTokens: 800, onFinish: async ({ text }) => saveChat(text) });

How to fix it

Stop the loop after a small number of steps, for example stopWhen: stepCountIs(10), and set maxOutputTokens.

Through a coding agent, Lintsure suggests the change and waits. Nothing is edited until you approve it.

Controls it relates to

  • OWASP LLM Top 10LLM06:2026Unbounded Consumption
  • API4:2023Unrestricted Resource Consumption

What the framework asks

OWASP LLM Top 10 LLM06:2026: Unbounded Consumption

Limit output size, request rate and cost per user, so one person can't run up a bill or take the service down.

Evidence a reviewer may ask for: Rate limits, spending alerts and usage monitoring.

API4:2023: Unrestricted Resource Consumption

Limit how often, how much and how long: request rates, page sizes, upload sizes, and anything you pay for per call.

Evidence a reviewer may ask for: The limits in code and at the gateway, and spending caps with providers.

Summaries are our own reading of the public texts, not the official wording.

Check your code for this

Runs on your machine. Your code is never uploaded.

npx lintsure scan

Quickstart · Use it in Claude Code or Cursor

This rule is in Beta: its mapping to framework controls is our own reading of the public texts, not independently reviewed. Lintsure is a readiness tool, not an audit or legal advice. A finding, or the lack of one, doesn't make you compliant. Disclaimer

We improve these rules all the time. If you see a false alarm, a missed problem or anything that could work better, tell us in a review and we will use it to improve your experience.

Related rules

Did this rule flag something that's fine, or miss a real problem? Tell us on GitHub. Every report becomes a test case, so the same mistake can't come back.