The overnight bill starts with one more turn
You ask a coding agent to fix a failing test, leave it running, and close your laptop. While you sleep, it keeps reading files, proposing edits, running tools, and checking results. Each step looks reasonable. Together, those steps can produce a bill you never consciously approved.
An agent loop is simply a repeated cycle: ask a model what to do, execute an action, send back the result, and ask again. The cost comes from those repeated model requests, not just from the original instruction. Before leaving one unattended, you need a spending estimate and a reliable exit.
Every turn can send the project back through billing
Models generally bill for input tokens, the text they receive, and output tokens, the text they generate. Tokens are small pieces of text. Your instructions, source code, conversation history, and tool results can all contribute to the input.
A tool command does not necessarily create a model charge by itself. But when its output goes back to the model, that text can become billable input. A long test log can therefore cost money on several later turns if the agent keeps including it.
Context management matters. Some agents trim history, summarize older messages, or use caching where supported. Others repeatedly send a growing conversation. Do not assume that the tenth request costs the same as the first.
Estimate one night with a simple token budget
Start with this formula: input cost plus output cost equals model spending. For prices quoted per million tokens, divide each token total by one million, multiply by its applicable rate, and add the results.
Here is a deliberately simplified example using invented prices, not SwiftRelay rates:
- The agent makes 100 model requests.
- Each request averages 12,000 input tokens and 1,000 output tokens.
- Total usage is 1.2 million input tokens and 100,000 output tokens.
- At hypothetical rates of $2 per million input tokens and $8 per million output tokens, the model bill is $3.20.
That is an illustration, not an overnight prediction. Larger contexts, extra retries, different model rates, and separately billed tools can change the total. Use the current pricing for your chosen model and usage from a short supervised run.
Catch the loops that spend without progressing
The expensive failure is often repetition. An agent may keep attempting a missing dependency installation, rerun an unchanged failing test, or alternate between two edits. It is still generating activity, but the task is not getting closer to completion.
Watch for repeated tool calls, identical error messages, and edits that undo earlier edits. These are useful signals for an automatic stop, not reasons to grant unlimited retries. A request that fails can also lead to additional attempts; check usage records rather than assuming every unsuccessful step was free.
Set stop rules before closing the laptop
- Cap spending: Use an enforceable budget control where available. An alert alone does not stop requests.
- Limit turns and retries: Set maximum model calls and a smaller retry allowance for the same failure.
- Define completion: Specify the exact test, file change, or artifact that ends the task.
- Stop on repetition: Pause after repeated identical failures or no meaningful change.
- Restrict risky tools: Require approval for deployments, purchases, destructive commands, and external writes.
- Test the shutdown: Confirm that your runner actually stops issuing requests when a limit is reached.
Give your first unattended run a small allowance
SwiftRelay is a practical option for token-billed model access through tools such as Claude Code, Codex, Gemini CLI, and OpenAI-compatible SDKs. Its pay-as-you-go billing makes actual usage important: check current rates and confirm which limits your agent runner can enforce. Do not assume the relay supplies every safeguard listed above.
Sign up for SwiftRelay to use the small gift credit for a supervised trial. Review the tokens consumed, inspect repeated steps, and choose a conservative budget before attempting an overnight run. The goal is not to keep the agent busy until morning. It is to finish a bounded task and stop.