Relay365Multi-model API relay desk
← All desk bulletins
Spend watchEN1 desk reads

Shift Note: Stop Agent Loops Before the Bill Climbs

A stalled agent can keep spending

An AI agent can look busy while making no useful progress. It might read the same file, retry a failing command, or ask a model to repair an answer that never passes its checks. If those actions trigger paid requests, the meter keeps running even though the task is stuck.

This is a runaway agent loop: a sequence of repeated actions without an effective stopping condition. You do not need to understand the code behind an agent to manage this risk. Start by deciding how much work it may attempt, how much money it may spend, and when it must return control to you.

One task can produce many paid requests

A chat exchange often feels like one question followed by one answer. An agent may turn your instruction into several rounds of planning, tool use, inspection, and revision. Each round can involve another model request.

The cost also depends on how much information each request carries. An agent may repeatedly send conversation history, file contents, and tool results. As that context grows, later requests can cost more than earlier ones. A tool action may also have its own charge, separate from the model request.

Choosing a model such as Gemini 2.5 Flash does not remove the need for limits. Check current pricing for your chosen model, but also control how often the agent can call it and how much context it sends.

Set the stop conditions before starting the job

Give every automated run a small, explicit allowance. The right allowance depends on the task, but it should be clear enough that you can tell whether the agent has exceeded it.

  • Set a maximum number of model requests or agent steps so repeated attempts eventually stop.
  • Set a time limit so an unattended task cannot continue indefinitely.
  • Set a spending limit for each run, and use a separate account or project limit where supported.
  • Limit concurrent workers because several agents can spend at the same time.
  • Require your approval before the agent increases its allowance or starts additional workers.

Check what each setting actually does. A dashboard alert may only send a notification. A hard limit should reject further work once its enforcement condition is reached. Neither should be assumed to cancel requests already in progress.

Make repeated failure a reason to pause

Retries are useful when a temporary connection problem interrupts a request. They become wasteful when the underlying problem cannot change without intervention. An invalid credential, missing permission, or impossible instruction usually needs a fix, not another identical attempt.

Use a limited retry count and a delay between attempts. Check for retries at multiple layers: your agent, its SDK, and a surrounding job runner may each retry independently. Together, they can produce more requests than you expected.

Add a progress check as well. If the same tool error or unchanged output appears repeatedly, pause the run and show the reason. For example, an agent editing a file should stop after repeated failed checks without a meaningful change.

Track spending while there is still time to stop

Record each run's request count, model, reported token usage, and estimated cost. Keep those records connected to the task so you can identify which job caused a spike. Avoid putting credentials or unnecessary private content in logs.

Usage reports can arrive after work has started or finished. Leave room below your actual spending ceiling for concurrent and unfinished requests. When enforcing a budget in your application, reserve an estimated allowance before launching each request, then reconcile it against reported usage afterward.

Keep the same controls when using Relay365

Relay365 fits workflows that need pay-as-you-go access to multiple model families through a relay desk. It works with Claude Code, Codex, Gemini CLI, and OpenAI SDK clients. That can make it convenient to manage model access, while loop limits still belong in the agent or application running the work.

If that setup fits your workflow, create a Relay365 account and begin with a short, supervised task. Check which billing controls are available, confirm that your agent stops when instructed, and review the recorded usage before increasing its allowance.

Further desk bulletins

Curious how it runs on your own code? Sign up →