Software Engineering

Reasoning used up the output limit and the answer came back empty

Reasoning tokens come out of the same output limit as the answer. With little room, it comes back empty and with no error, and the default reasoning level can cost more without answering better.

Rodrigo Lucas · · 9 min read

The first eval of an agent with tools that I built showed between 12% and 17% empty answers, with no error at all in the log. There was no exception and no error status, just a string with no content where the text should be, and the provider's bill kept arriving all the same. The agent's main task (a multi-step plan assembled by a tool) only came out complete in 58% of requests.

I had turned on the model's reasoning expecting better answers and kept the output limit I always used. The cause was in that combination, not in the prompt or the tools. Reasoning tokens come out of the same output limit as the answer, so a limit sized for a model that does not think is too small for one that does. When reasoning uses up the whole limit, the answer comes back empty or truncated and the reasoning is billed anyway. The only sign of it is in the stop reason. The three big providers document this rule, but almost nobody reads it before having the problem.

Measuring turned up a second thing. In my agent, the default reasoning level tied in quality with the low level, cost about 45% more and took 2.6 times as long. And none of this shows up unless the eval counts an empty answer as a failure, because without that number the problem becomes "the model sometimes doesn't answer".

Why the answer comes back empty#

Reasoning (thinking in Gemini and Claude, reasoning at OpenAI) is a sequence of tokens the model generates before the answer, so it counts as output for billing and for limits. All three documentations say these tokens are billed as output, even when you only get a summary of the reasoning or none of it.

Every provider has a parameter that caps how many tokens the model can generate in one call. For years that number was thought of as the maximum size of the answer, and with reasoning it becomes the maximum size of the reasoning plus the answer. The model spends tokens in order, thinking first and writing after, without setting aside part of the budget for each phase. If the thinking consumes the whole limit, the writing phase never starts. What comes back is a technically valid response, with the stop reason saying the limit was reached and the text field empty.

Anthropic describes the case in a way that applies to all three: a max_tokens sized for a response without reasoning is often too small once the model starts thinking on hard requests. Gemini's thinking page says that if the model hits the limit while thinking, it returns truncated or empty output and bills the thinking tokens already generated. OpenAI warns that the cutoff can come before any visible token, and then you pay for input and reasoning without receiving an answer.

In my agent the limit was 1,500 tokens, a number that made sense for the answers I expected (short, with a few tool calls). With the model's default reasoning level, some of the more complex requests spent almost everything thinking and the final text came out empty.

// The configuration that looked reasonable
const response = await model.generateContent({
  contents,
  generationConfig: {
    maxOutputTokens: 1500, // sized for the answer
    // no thinkingConfig: the model's default level applies
  },
});

response.text; // "" on some requests, no exception

Why nobody notices#

No layer treats the case as an error. The SDK returns a normal response object and the HTTP status is 200. If your code only reads the text, it gets an empty string and moves on. In a chat interface, the user sees a blank bubble and tries again. In a multi-step agent, an empty step can be read as "the model decided to say nothing", and then the loop ends early.

The problem is also intermittent. Simple requests fit in the limit with room to spare because the model thinks little, and the only ones that overflow are those that need more reasoning, exactly the ones that made you turn reasoning on. In a manual test with three or four questions, everything works.

At first I was also measuring wrong, because a bug in the eval runner inflated the count of empties (the story is in the post about agent evals). And an empty answer does not have a single cause. In another project, the answers with no text came from the provider's safety filter, which was blocking legitimate domain content, unrelated to the limit. Limit, filter and runner bug produce the same symptom, and what tells them apart is the stop reason.

The stop reason is already in the response#

All three providers say why they stopped and how many tokens went to reasoning. What is missing, almost always, is code that reads these fields. I checked the names below in each provider's documentation in November 2026 (for Gemini, they are the ones from the generateContent API).

GeminiAnthropicOpenAI (Responses)
Limit that includes reasoningmaxOutputTokensmax_tokensmax_output_tokens
Signal that the limit cut it offfinishReason: "MAX_TOKENS"stop_reason: "max_tokens"status: "incomplete" with incomplete_details.reason: "max_output_tokens"
Reasoning tokensusageMetadata.thoughtsTokenCountusage.output_tokens_details.thinking_tokensusage.output_tokens_details.reasoning_tokens
How much to thinkthinkingConfig.thinkingLevel (or thinkingBudget, in tokens)output_config.effortreasoning.effort
DocumentationThinking, generateContentSteering thinkingReasoning models

With these fields, a few lines turn the silent empty answer into an error that shows up in the log.

const candidate = response.candidates?.[0];
const text = response.text ?? "";
const usage = response.usageMetadata;

if (!text && candidate?.finishReason === "MAX_TOKENS") {
  log.warn("reasoning_exhausted_limit", {
    limit: MAX_TOKENS,
    reasoning: usage?.thoughtsTokenCount,
    answer: usage?.candidatesTokenCount,
  });
  throw new TruncatedResponse(); // treat it as a failure, not as silence
}

From there you have a metric, the fraction of calls in which reasoning used up the whole limit. And with thoughtsTokenCount logged on every call, you can see how much each kind of request really thinks before choosing the limit.

Raise the limit or reduce the reasoning#

There are two ways to make room for the answer, and Anthropic's documentation describes both for when stop_reason: "max_tokens" shows up. If the truncated requests needed that reasoning, raise the limit. If the model overthought, lower the effort. Gemini's documentation points the same way and recommends lowering the reasoning level, instead of tightening the output limit, to reduce cost or latency without truncating the answer.

In my agent I did both and measured.

const MAX_TOKENS = Number(process.env.MAX_TOKENS ?? 4000);
const LEVEL = process.env.REASONING_LEVEL ?? "low";

const response = await model.generateContent({
  contents,
  generationConfig: {
    maxOutputTokens: MAX_TOKENS, // headroom for reasoning + answer
    thinkingConfig: { thinkingLevel: LEVEL },
  },
});

With a 4,000-token limit and a low reasoning level, compared with the old configuration (1,500 tokens and the default level), the eval changed like this:

  • the answer rate went from 85% to 96%;
  • the complete main task went from 58% to 100% of requests;
  • the cost of the eval dropped 27%;
  • the median time per request went from 20 to 15 seconds.

I found it odd that raising the limit did not raise the cost, until I remembered that the limit is a ceiling and the model is not required to spend all of it. What decides the spend is how much it thinks, and the reasoning level controls that.

I left both changes as environment variables on purpose. When the next version of the model comes out with different behavior, adjusting means changing a value and running the eval, without opening a PR.

The provider's default is for an average case#

I tested the default level against the low one, on the same set of eval scenarios. The default tied in quality, cost about 45% more and took 2.6 times as long. In an agent with tools, a good part of the work is deciding which tool to call and with which arguments, and thinking more brought no gain that the checks could measure.

The default also changes from model to model within the same provider. In Gemini's table, some models start at minimal, others at medium and others at high. At Anthropic, high is the default on most models and some start at medium. OpenAI says the accepted values depend on the model. If you rely on the default, cost and latency can change when you switch models without you touching a line of configuration.

This result does not become a rule of "always use the low level", and I have two reasons to be wary of it. My eval measures what the checks can see (whether there was an answer, whether the right tool was called, whether the task came out complete). A subtle gain from the default level on hard requests the eval does not cover would be invisible, and less reasoning on those requests is exactly the price of the switch. The other reason is that headroom in the limit avoids the cutoff but does not hold back the spend. A generous limit lets a pathological request think a lot, and at Anthropic, in a tool loop, each call has its own max_tokens, which does not cap the whole turn. If cost per request matters, the spending cap has to live outside the model, per user or per day, along with the cutoff alert.

What I would look at next#

The 4,000 limit held up in the eval, which covers the scenarios I wrote. To know whether it has real headroom or only enough for those scenarios, the right data is the distribution of thoughtsTokenCount per kind of request in production, and this post does not have that data. That is the next measurement I would take, and again on every model switch, since the default reasoning level and how much the model thinks can change without notice.

References#

updated on

01 blog

related

02 blog

Who writes

Contact

Let's swap ideas

Get the next articles

No spam, one email when a new article ships. Unsubscribe anytime.