Skip to content
VibecodeZero

AI agent stuck in a loop and burning credits: stop it

Updated First published

On this page (4)
  1. Symptom
  2. Cause
  3. Prompt to paste
  4. How not to burn credits

Symptom

You ask the AI to fix an error, it says it's fixed, and the same error comes back. Or it fixes one thing and breaks another, then changes it back. Meanwhile your credits or tokens keep going down.

Cause

An AI agent can’t see your app the way you do. When its fix doesn’t work, it often tries the same idea again, or undoes its last change and tries the one before. Each round uses credits, tokens or API spending, and nothing gets better. This page shows how to break the loop and how to cap what the next one can cost.

The Lovable facts below come from its docs on credits and usage and usage limits and alerts, checked October 22, 2026. Facts about Bolt and about API spending limits come from our pages linked in each section, which name their own sources.

How do I know I’m in a loop?

You’re probably in a loop if:

  • The same error comes back after the agent says it fixed it.
  • The agent undoes its own fix. It changes something, then changes it back, or swaps between two versions.
  • One bug has taken three or more tries and nothing changed, except your balance.
  • Each fix breaks something else, and the next fix brings back the first problem.

Asking again with the same words usually brings the same answer. The way out is to stop, step back and give the agent something new: the exact error, what it already tried, and a request to explain before it acts.

Step 1: stop the agent

Don’t send another message while it’s still running in circles. Stop it first.

In Lovable, its docs say a stopped Build mode request is charged based on the work completed so far, and that a request you stop before Lovable has made any change to your project isn’t charged. You can see what a reply has cost in the More options menu below it, under Credits used, even while Lovable is still working.

Lovable also has credit check-ins for long Build mode messages. When one message passes your check-in level, 20 credits by default, the run pauses with a card showing what it has cost so far. Choose Continue to keep going or Finish up to wrap up and stop. Lovable’s docs say a check-in is a notification, not a hard cap, and that the feature is in beta.

One thing to avoid: Lovable’s docs say a Build mode message set as a goal with the /goal command costs noticeably more, and Lovable keeps working until the goal is achieved. That’s the opposite of what you want with a bug you’re already stuck on.

Step 2: go back to the last version that worked

Stacking more fixes on broken code makes the next fix harder. Go back first, then ask again.

  • Lovable: click Undo latest edit under Lovable’s last reply, or open History in the top bar and revert to the last version that worked. You can also hover over your own earlier message, click Edit message and choose Revert and resend. Reverting brings back the code, not the data in your database. More in Lovable build errors.
  • Bolt: restore a previous version from Version History. That doesn’t use tokens, while asking Bolt in the chat to revert does. Repeated Attempt fix clicks use tokens each time. More in Bolt tokens explained. If Bolt seems confused about the whole project, clearing its context can help: see Bolt not responding.

Step 3: send one clear message with the exact error

Now send the prompt on this page. It asks the agent to stop changing code, list what it tried, explain why each try failed and propose one next step, then wait for you.

Paste the exact error message, not “it’s broken”. If there’s no message, describe exactly what you did and what happened. Then read the answer before you say yes.

Send it where the agent can’t edit your code. In Lovable, that’s Chat mode: its docs say that in Chat mode Lovable doesn’t edit your project’s code. In Bolt, use Plan mode. If the agent keeps saying it’s fixed when it isn’t, The AI says it fixed it, but the error is still there has more on that.

If it still fails: park the feature and publish the rest

If a clean, smaller attempt from the last version that worked still fails, park the feature. This isn’t giving up. It keeps one problem from blocking everything else.

  • Write it down for later: what it should do, what you tried and what happened.
  • Hide it from the app, so nobody clicks a button that doesn’t work. Ask the AI: “Remove the booking button from the menu for now. Don’t change anything else.” Then check the rest still works.
  • Publish the version that works and use it for a few days. You’ll often find the feature needs to work differently, or that you don’t need it at all.

Login, payments and saved data online often behave differently in the preview and on the live site, so it’s normal for those to take more than one session. How hard is vibe coding, really? explains why.

Step 4: cap spending before the next loop

A loop only gets expensive when nothing stops it. Set a cap that blocks, not just one that warns.

Lovable usage limits. On paid plans, workspace owners and admins can create limits in Workspace settings → Usage limits & alerts. For loops, the useful one is a limit on the project (or the whole workspace) with the Build credit type, a Daily or Monthly period and Block building turned on. New limits start with blocking and email alerts turned on. Lovable marks a blocking limit as Approaching at 80%, in a Requires attention card at the top of the page, and stops building when the limit is reached. Daily limits reset at 00:00 UTC, monthly ones on the 1st at 00:00 UTC. Usage can go slightly past the limit before the block takes effect, so treat it as a strong guardrail, not an exact cutoff. A low-balance alert, on the other hand, never blocks anything.

Pick the credit type with care. A Build limit only stops building and editing. Limits that block Cloud, like Pause Cloud, Pause Cloud and AI features and connector requests or Block all usage, pause the backend of the published apps they cover, so your visitors can’t sign in or load data. Adding credits doesn’t lift that kind of block. If it already happened, see My published Lovable app stopped working.

API keys. If your agent runs on your own API key, as with OpenCode, or Claude Code with an API key, set a hard limit at the provider before you start. OpenAI says spend alerts alone don’t stop API traffic. Set an API spending limit before you paste your key has the steps for OpenAI, the Claude Console and OpenCode Console. If the agent is slow or failing rather than looping, and you use OpenCode, see OpenCode slow or failing on a free model?. If you use Claude Code on Pro or Max and your usage limit drains fast, see Claude Code usage limit draining fast?.

Plan credits. If the loop already used up your credits or tokens, I ran out of credits in the middle of my project says when free limits reset and what still works while you wait. To understand how each tool counts usage, read Lovable credits explained and Bolt tokens explained.

Prompt to paste

Copy the text below, replace what’s in brackets and send it in the chat of the tool you’re using.

Paste into the AI
Stop. Don't change any code in this message.

The same problem keeps coming back. The exact error is:
[paste the error message here, or describe exactly what you see]

In plain English, tell me:
1. What you have tried so far to fix this, one line each.
2. Why you think each try didn't work.
3. One next step you would take, and why it's different from what you already tried.
Then wait. Don't do anything until I say yes.

How not to burn credits

  • Count your tries. After three on the same bug, stop and use the prompt on this page instead of another "fix it".
  • In Lovable, stop a run that's going in circles. Lovable's docs say a stopped Build mode request is charged for the work done so far, and isn't charged at all if Lovable hasn't changed your project yet.
  • Watch the cost while it runs. In Lovable, the More options menu under a reply shows Credits used, even while Lovable is still working.
  • Go back with buttons, not prompts. In Bolt, restoring from Version History doesn't use tokens, while asking Bolt to revert does. In Lovable, use History or Undo latest edit.
  • Ask before you build. Send the prompt on this page in Lovable's Chat mode, where Lovable doesn't edit your code, or in Bolt's Plan mode.
  • Don't hand a stuck bug to /goal in Lovable. Its docs say a goal costs noticeably more and keeps working until the goal is achieved.
  • Before your next long session, set a cap that blocks. Alerts only tell you after the money is spent.

How Lovable counts credits, and what the free plan includes: Lovable credits explained.

Questions people ask

How do I know my AI agent is stuck in a loop?

Look for three signs. The same error comes back after the agent says it fixed it. The agent changes something, then changes it back. Or one bug has taken three or more tries. If you see any of these, more "fix it" messages will most likely spend more without fixing anything. Stop and ask the agent to explain what it tried, with the prompt on this page.

Am I charged if I stop Lovable in the middle of a task?

Lovable's docs say a stopped Build mode request is charged based on the work completed so far. A request you stop before Lovable has made any change to your project isn't charged. For long Build mode messages, Lovable also checks in when one message passes 20 credits by default, so you can choose Continue or Finish up. That check-in is a warning, not a hard cap, and the feature is in beta.

Can I make Lovable stop spending credits at an amount I choose?

Yes, on paid plans, if you're a workspace owner or admin. In Workspace settings → Usage limits & alerts, create a usage limit for the project or the workspace with the Build credit type, a daily or monthly period and Block building turned on. Lovable marks the limit as Approaching at 80%, with an early warning if its alerts are on, and blocks building when the limit is reached. Its docs say usage can go slightly past the limit, and that low-balance alerts never block anything.

Will a usage limit take my published Lovable app offline?

A Build limit doesn't. It only stops building and editing. But workspace and project limits that block Cloud, such as Pause Cloud or Block all usage, pause the backend of the published apps they cover. The pages still load, but login, the database and storage stop. If that happened, see My published Lovable app stopped working.

How do I cap spending on an API key my agent uses?

Set a limit at the provider that blocks requests, not just an alert. OpenAI says spend alerts alone don't stop API traffic and recommends monthly limits with hard enforcement. The Claude Console has spend limits on the Billing page, and OpenCode Console has monthly budgets. Our guide to setting an API spending limit has the steps for each one.

New guides by email. An email when we publish a new guide, error fix or chapter, in plain English. Subscribe