Coding agent cuts off file writes or stops mid-answer: the output limit

Updated 13 November 2026

If a coding agent writes half a file, stops mid-sentence or reports a malformed edit after you point it at a custom endpoint, the usual cause is the maximum output size. Every request has a ceiling on how many tokens the model may generate. When a reply reaches it, the model is cut off wherever it happens to be.

The lower of the two caps wins. Whatever the model hadn't written by then is simply missing.

How to confirm it

Look at the response's finish reason. If it's length (OpenAI-style APIs) or max_tokens (Anthropic-style APIs) instead of stop or end_turn, the reply hit a cap. The cut-off also falls at about the same size every time, because the cap is a fixed number. On NeverMetered, the Requests page shows output tokens per request, so you can see them stop at your plan's cap.

Why it happens

Two caps apply and the lower one wins: the one your tool asks for (max_tokens) and the one the endpoint allows. Coding agents ask for large outputs because a whole-file write can be long. If the endpoint's cap is lower than the request, the server limits it, and the agent sees a reply that ends early with no error. Many tools don't flag that it was cut off, so what you notice is a broken file rather than a clear failure.

Fixes

  1. 1

    Tell the tool the real cap

    Set the tool's maximum output to your plan's value. For Claude Code that's the CLAUDE_CODE_MAX_OUTPUT_TOKENS variable, which the Claude Code setup writes for you. Other tools have an equivalent setting for output or completion tokens.

  2. 2

    Ask for smaller steps

    Instead of one reply that rewrites a large file, ask the agent to edit sections, or split the file. Agents that apply targeted edits rarely come near the cap.

  3. 3

    Check the context window too

    Output counts toward the context window. A request whose input already fills most of it leaves little room to answer. See the context fix and what a context window is.

  4. 4

    Use the setup commands, not a hand-built config

    The setup in your dashboard fills in your plan's context window and output cap, so the tool and the endpoint agree.

Some plans allow larger outputs than others. Your plan's exact output cap is on the pricing page and in your dashboard's setup dialog.
Why does my agent say the file was written but it's cut off?
The model's reply ended at the output cap, and the tool wrote what it received. The tool may not know it was cut off. Check the finish reason, then use the fixes above.
Does this only happen with custom endpoints?
It can happen anywhere, but a vendor's own tool is tuned to its own cap. A custom endpoint needs the tool told the cap, which is why a setup that fills it in matters.
Sources