Interrupting a Coding Agent: What Gets Billed?
You start a coding agent, watch it inspect your project, and realize it is solving the wrong problem. You press Escape or stop the process. The text stops appearing, but what happens to the bill? The answer depends on which requests already ran, how cancellation travels through the system, and what usage the provider records.
Follow one interrupted task from the initial prompt to the final usage record. The key distinction is between stopping the interface, stopping generation, and accounting for work already performed.
Step 1: Identify what the agent has already sent.
Suppose you ask an agent to fix a failing test using Claude Sonnet 5. Before you see a reply, the client may send your instructions, system instructions, conversation history, tool definitions, and selected repository content. Those become input tokens under the applicable pricing rules.
Interrupting after submission does not make that input disappear. An accepted request may already have incurred billable work before its first visible token arrives. Cached input can have different pricing, so the full context size alone does not establish the charge.
Step 2: Separate the agent run into individual requests.
A coding agent usually performs several operations: request a model response, run a search or shell command, return the result to the model, and request another response. A single task can therefore contain multiple billable model calls.
If you interrupt during the fourth call, the first three calls remain part of the task's usage. Tool results included in later requests can also increase input tokens. A local file search is not itself model output, although a hosted tool or execution service may have separate charges.
Step 3: Understand what the visible stream measures.
Streaming delivers output incrementally, which helps you spot a wrong direction sooner. It does not make the displayed text a complete billing meter. Network chunks do not necessarily correspond to single tokens, and an interface may buffer text before displaying it.
The provider may also account for output that your screen never displays, including tokens generated before cancellation takes effect. Some models have separately reported reasoning usage. Check the applicable usage fields and pricing rather than estimating the bill from the answer's visible word count.
Step 4: Trace what the stop button actually cancels.
A stop action can halt rendering, close a connection, abort an HTTP request, or invoke a supported cancellation mechanism. These actions have different effects. Closing your terminal does not, by itself, prove that every upstream operation stopped immediately.
Cancellation takes time to propagate from the client through any relay to the provider. More output may be generated during that interval. A shell command the agent already launched may also continue unless the client explicitly terminates it. Check your agent's documented behavior for both model requests and running tools.
Step 5: Reconcile the charge with recorded usage.
Imagine a completed request reports 12,000 billable input tokens and 800 billable output tokens. Its token cost follows the applicable input and output rates, with any caching or other pricing distinctions applied. Stopping a later request does not reverse that completed charge.
For the interrupted request, inspect the provider or relay's usage record. Some APIs deliver usage near the end of a stream; disconnecting early can prevent your client from receiving it. A missing final usage event does not establish that the request was free. Keep request identifiers so you can match client logs to billing records.
Step 6: Make the next attempt easier to control.
Give the agent a narrow first task, ask it to inspect before editing, and use supported output limits or spending controls. These measures help you catch an incorrect assumption before repeated calls accumulate.
Fluxio fits workflows that need streaming across supported models through one API key. Its pay-per-token relay works with Claude Code, Codex, Gemini CLI, and OpenAI SDK clients. Use https://api.fluxioapi.com as the base, adding /v1 for OpenAI-style clients. Confirm cancellation behavior and usage reporting for your chosen client and route before relying on interruption to control spending.
Sign up for Fluxio to try streaming AI workflows.