Notas / 07
Reasoning model empty content: three causes
The request succeeds, finish_reason looks plausible, and message.content is empty. Three different faults produce that symptom and they need three different fixes, so the useful question is not "why is the model broken" but "where did the answer go". This article builds a probe that prints the reasoning trace, the finish reason and the token split for every call, then walks the causes in order of frequency: a token budget consumed entirely by thinking, a client reading the wrong field, and a turn that ended waiting for a tool result. It ends with an escalation helper that raises the budget only when the evidence supports it.
The probe
Reasoning output arrives as reasoning_content, a sibling of content. The OpenAI SDKs do not type it, so you have to reach into the raw object — model_extra in Python, a cast in Node. Print all three facts together, because any one of them alone points at the wrong cause.
#!/usr/bin/env python3
"""reasoner_probe.py — find out where the answer went."""
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["MODELRY_API_KEY"],
base_url=os.environ.get("BASE_URL", "https://api.tokenaimodels.com/v1"),
timeout=300.0,
max_retries=1,
)
def think(prompt: str, budget: int = 8_000) -> dict:
resp = client.chat.completions.create(
model="deepseek-reasoner",
messages=[{"role": "user", "content": prompt}],
max_tokens=budget,
extra_body={"reasoning_effort": "medium"},
)
choice = resp.choices[0]
msg = choice.message
reasoning = (
getattr(msg, "reasoning_content", None)
or (getattr(msg, "model_extra", None) or {}).get("reasoning_content", "")
or ""
)
details = getattr(resp.usage, "completion_tokens_details", None)
return {
"content": msg.content or "",
"reasoning_chars": len(reasoning),
"reasoning_preview": reasoning[:300],
"finish_reason": choice.finish_reason,
"completion_tokens": resp.usage.completion_tokens,
"reasoning_tokens": getattr(details, "reasoning_tokens", None) if details else None,
}
def answer(prompt: str, budgets: tuple[int, ...] = (2_000, 8_000, 24_000)) -> dict:
last = {}
for budget in budgets:
last = think(prompt, budget)
if last["content"].strip():
return last
print(f"empty content | max_tokens={budget} "
f"finish={last['finish_reason']} "
f"completion={last['completion_tokens']} "
f"reasoning_chars={last['reasoning_chars']}")
if last["finish_reason"] != "length":
break # a bigger budget will not help
return last
if __name__ == "__main__":
r = answer("Prove that the square root of 2 is irrational, then state the key step in one sentence.")
print("---")
print("content:", r["content"][:400] or "<EMPTY>")
print("reasoning preview:", r["reasoning_preview"] or "<none>")
Cause 1: the budget was spent thinking
max_tokens covers thinking plus answer. A hard problem with a 2,000-token budget can spend all of it reasoning and return nothing at all, with finish_reason: "length". The signature is unambiguous: completion_tokens equals your max_tokens, and reasoning_chars is large. Raise the budget — 4,000 is a floor for a reasoning model and 8,000–16,000 is normal for real work — and check finish_reason on every response rather than assuming success. Note the ceiling too: output is clamped to the model maximum instead of being rejected, so asking for more than the maximum silently gives you the maximum, and length remains your only evidence.
Cause 2: you are reading a field that does not exist
message.content is empty because the text you want was never in it. Two variants. In a streaming client, the trace arrives as delta.reasoning_content and the answer as delta.content; a handler that only prints delta.content shows nothing for tens of seconds, which reads as "empty response" in a UI even though tokens are flowing. In a non-streaming client, the SDK's typed model has no reasoning_content attribute, so msg.reasoning_content raises or evaluates to None depending on the SDK version, and code that then falls back to msg.content prints nothing. Read the raw field through model_extra (Python) or a cast (Node), as the probe does, and log reasoning_chars — a non-zero count proves the model worked and the reader did not.
Cause 3: the turn ended waiting for a tool result
When a model emits a tool call, content is null by contract and finish_reason is tool_calls. Nothing is broken: the assistant asked a question and your loop is supposed to answer it. This shows up as "empty content" the moment someone adds tools to a call that previously worked, and it is especially confusing on a reasoning model because the trace is full of confident prose about what it is about to look up. Branch on finish_reason before you touch content: stop means the answer is in content, tool_calls means execute and continue, length means the budget ran out.
What to watch when you speak to a gateway instead of OpenAI
Reasoning traffic is the most expensive traffic you have, and three gateway behaviours interact with it. Default effort: the gateway may set reasoning_effort to a middle value on your behalf; if you never send it, your latency and cost are being decided by a default you did not choose. Send it explicitly, and drop to low for classification and extraction where the trace adds nothing. Thinking on the chat tier: the fast model ships with thinking disabled; enabling it via the DeepSeek-style thinking switch makes the same request cost several times more, so enable it per workload, not globally. Timeout budget: long traces are the usual victim of the request wall-clock limit, so stream, raise the client idle timeout, and remember that failover only happens before the first token, and only where a second channel is configured — a 90-second thinking phase that then fails is a request you pay for twice.
Choosing a budget from evidence
Do not pick max_tokens from advice; measure it. Run twenty of your real production prompts at a deliberately generous budget, record reasoning_tokens and completion_tokens for each, and set the per-workload budget to roughly the 95th percentile of the sum plus a margin. Two patterns show up almost immediately. Classification and extraction settle at a few hundred reasoning tokens, where the expensive tier is wasted work and the fast tier with thinking disabled is the correct tool. Multi-step proof and refactor tasks have a long tail: the median may be two thousand tokens while the p95 is twelve thousand, and a budget set at the median produces intermittent empty responses that look random and are not.
The second pattern is effort. Going from medium to high raises both the trace length and the latency, and on most workloads the gain is concentrated in a small fraction of requests. Route by task, not by preference: send the easy ones to the fast tier, reserve the reasoning tier and high effort for the requests that already failed a fast-tier attempt. A retry ladder — fast tier first, reasoning tier second — usually beats sending everything to the expensive path, and it is measurable rather than a matter of taste.
Finally, keep the trace. It is the most useful debugging artefact a reasoning model produces: when an answer is wrong, the trace often shows the wrong assumption three sentences before the wrong conclusion. Log reasoning_chars and the finish reason on every call even if you never render the trace, because those two numbers are what distinguish "the model thought and answered", "the model thought and ran out of room", and "the model never spoke at all".
One more guard, because it produces the same symptom: in a streaming client the answer can arrive *after* a long quiet period, so a UI that renders only what has arrived so far looks empty while the trace is still streaming. Render delta.reasoning_content in a collapsed panel as it arrives, and show a spinner labelled with the elapsed time; the user then sees progress instead of a blank box, and you can tell a slow answer from a missing one.
Create a key at https://tokenaimodels.com and run the probe against deepseek-reasoner with the hardest question you actually ask in production — the token split it prints is the budget you should be setting.
A Modelry opera uma plataforma que serve modelos DeepSeek atrás de um único endpoint HTTP, com créditos pré-pagos e impostos tratados pelo merchant of record no checkout, além de uma política de retenção de dados documentada. Comece com $0.50 de crédito de teste: criar uma chave.