OpenAI Codex stops with "Incomplete response returned, reason: max_output_tokens": causes and fixes

Last verified: November 28, 2026
Codex users and developers calling the OpenAI Responses API are seeing tasks stop halfway with the message "Incomplete response returned, reason: max_output_tokens". The model did start working, the request was accepted and billed, but the answer never arrived or arrived cut short. In most cases the model ran out of output budget, and hidden reasoning counts toward that budget, so a model thinking at a high effort level can use the whole allowance before it writes a single visible word.
The fix depends on where you see the message. In your own API code you control the limit directly and can raise it, lower the reasoning effort or ask for less output. In Codex the output limit is set by the client and the model, so the levers are reasoning effort, the size of the task, compaction settings and, in a few reported cases, switching to another model. The message has been reported on macOS and Windows, in the Codex CLI, in `codex exec` automation and in the Codex desktop app, with GPT-5.6 Sol, GPT-6 Astra, GPT-6 Luna and GPT-6.1 Sol named in the reports.
··········
WHERE THE MAX_OUTPUT_TOKENS MESSAGE APPEARS IN CODEX AND THE RESPONSES API.
The wording changes with the tool and the version, which is why searches for it return a mix of unrelated threads. Codex builds such as 0.144 and 0.154 printed the text with a prefix, "stream disconnected before completion: Incomplete response returned, reason: max_output_tokens". According to a merged pull request in NVIDIA's NeMo Gym project, which had to update its Codex adapter to recognize the new text, Codex 0.163.0 prints it without the prefix. The prefixed form is easy to confuse with the network error covered in our guide to Codex "stream disconnected before completion", but the reason at the end of the line tells the two apart: a network drop has no token reason attached.
........
Where you see it | Exact text or field | What it means |
Codex CLI 0.163.0 and later | Incomplete response returned, reason: max_output_tokens | The model hit its output cap before finishing the turn |
Codex CLI 0.144 and 0.154 | stream disconnected before completion: Incomplete response returned, reason: max_output_tokens | Same cause, older wording |
Codex desktop app, compaction | Error running remote compact task: Incomplete response returned, reason: max_output_tokens | The summary written during history compaction ran out of output budget |
Responses API | status "incomplete", incomplete_details.reason "max_output_tokens" | The response stopped at the max_output_tokens value or at the context window limit |
........
OpenAI's reasoning guide gives the official definition for the API. If the generated tokens reach the context window limit or the max_output_tokens value you set, the response comes back with a status of incomplete and a reason of max_output_tokens. The guide adds that this can happen before any visible output is produced, so you pay for input and reasoning tokens without receiving an answer.
··········
WHY REASONING TOKENS USE UP THE CODEX AND API OUTPUT BUDGET.
Reasoning models generate internal reasoning tokens before writing the reply. They are never shown in the API output, yet the reasoning guide states that they occupy space in the context window and count toward max_output_tokens, which limits the total generated tokens including reasoning. The exact reasoning count is reported in the usage object under output_tokens_details. On October 19, 2026 an OpenAI support agent confirmed the same point on the official developer forum: output usage includes reasoning and other non-visible tokens, and the response may show the incomplete status with this reason.
Reasoning effort controls how much of that hidden work the model does. The guide lists the supported values as model-dependent, among none, minimal, low, medium, high, xhigh and max. Higher effort produces more reasoning tokens per turn, so a limit that was comfortable at medium can run out at xhigh. OpenAI's advice for anyone starting with these models is to reserve at least 25,000 tokens for reasoning and outputs. A limit of a few thousand tokens, common in older code written for non-reasoning models, is a common source of the empty responses reported on the forum: one developer saw streaming output stop at exactly 2,048 tokens with no text, and the request completed once the limit was raised substantially.
··········
CODEX AND RESPONSES API MAX_OUTPUT_TOKENS: CAUSES, CHECKS AND FIXES.
The table separates the causes OpenAI documents from those that come only from user reports or open GitHub issues.
........
Cause | How to check | Fix | Source |
max_output_tokens set too low for a reasoning model | usage.output_tokens equals your limit; output_tokens_details shows most tokens as reasoning | Raise the limit, starting from at least 25,000 tokens | OpenAI reasoning guide |
Reasoning effort too high for the budget | Same symptom appears only at high, xhigh or max | Lower model_reasoning_effort in Codex or reasoning.effort in the API | OpenAI reasoning guide |
Context window nearly full | Very large input, long sessions, many files read | Shorten the input, start a new session, let compaction run earlier | OpenAI reasoning guide |
Compaction summary exceeds its own budget (Codex app) | Message starts with "Error running remote compact task" | Start a new task or switch model; no official fix yet | Open GitHub issue #60652 |
Repetition loop inside tool-call arguments | Output tokens at the cap, function-call arguments full of whitespace | Client-side guard, cap the limit, validate arguments before running tools | Forum reports, unconfirmed by OpenAI |
codex exec with --output-schema returns at once | Error on the first call of exec or resume, zero usage counters | No fix yet; track the issue | Open GitHub issue #58728 |
........
··········
FIXING THE INCOMPLETE STATUS IN YOUR OWN RESPONSES API CODE.
When you call the API directly, every lever is in your hands. The steps below follow the order OpenAI's documentation implies, from the cheapest change to the most invasive.
1. Check the response before reading output_text. The reasoning guide's examples test whether status equals "incomplete" and incomplete_details.reason equals "max_output_tokens", then print the partial output if there is any, or report that the model ran out of tokens during reasoning.
2. Read the usage block. If output_tokens matches your max_output_tokens value and reasoning_tokens makes up most of it, the model never reached the answer.
3. Raise max_output_tokens. OpenAI recommends reserving at least 25,000 tokens for reasoning and outputs while you experiment. The guide's own example uses 300 tokens only to demonstrate the incomplete case.
4. Lower reasoning.effort for tasks that do not need deep reasoning, such as classification, extraction or short rewrites.
5. Shrink the input when it is close to the model's context window, because the guide names the context window limit as the other trigger for the same status.
6. On a retry, send the request again with the larger budget. A forum user asking whether a stopped response could be continued from the cut-off point was told by other developers that it cannot, and that splitting the content is the practical alternative; OpenAI does not document a resume mechanism for this case.
The snippet below is illustrative and reproduces the check from OpenAI's reasoning guide in Python form.
# Illustrative: the incomplete-response check described in OpenAI's reasoning guide
if (
response.status == "incomplete"
and response.incomplete_details.reason == "max_output_tokens"
):
if response.output_text:
print("Partial output:", response.output_text)
else:
print("Ran out of tokens during reasoning")The same budget logic applies to other providers: Gemini returns finishReason MAX_TOKENS with an empty reply when thinking consumes the limit, a case covered in our guide to the Gemini API empty response with MAX_TOKENS. The parameter names themselves differ between Chat Completions, Responses, Claude and Gemini, and our reference to OpenAI, Claude and Gemini token-limit parameters lists each one.
··········
[[ADPLUS_300x250_1]]
FIXING "INCOMPLETE RESPONSE RETURNED" IN THE CODEX CLI AND DESKTOP APP.
Codex is harder to fix because the Codex configuration documentation does not list any key that sets the API's max_output_tokens value. What it does document are the settings that change how many tokens a turn consumes: reasoning effort, reasoning summaries, verbosity, the context window and automatic compaction. User-level settings live in ~/.codex/config.toml, and project-scoped overrides can sit in a .codex/config.toml file that Codex loads only for trusted projects.
1. Lower the reasoning effort for the task. The config sample describes model_reasoning_effort as the effort advertised by the selected model, with supported levels that vary by model and client. Dropping from xhigh to high or medium leaves more of the output budget for the actual answer.
2. Give Codex smaller steps. A single request to refactor a whole repository or write several large files in one turn asks for more output than one response can hold. Splitting the work into separate prompts keeps each turn under the cap.
3. Keep the context lean. Long sessions fill the context window, which the API documentation names as the second trigger for the same status. Start a new session for a new task, or adjust compaction so it runs earlier.
4. Tune compaction if the error appears during it. The configuration reference documents model_auto_compact_token_limit, the token threshold that triggers automatic history compaction, and model_post_turn_compact_threshold_percent, which compacts after a final response once the context reaches a set percentage of the usable window.
5. Update Codex and check the model. If the message appears together with a version warning, follow our guide to "The model requires a newer version of Codex" first, since an outdated client can mishandle new models.
6. Report persistent cases. OpenAI support's advice on the forum was to contact support@openai.com when the problem continues; for the CLI, the openai/codex GitHub repository is where the open issues are tracked.
The keys below come from the official Codex sample configuration; the values are examples, and the right reasoning level depends on the model you use.
# ~/.codex/config.toml (keys from the Codex sample configuration)
model_reasoning_effort = "medium"
model_reasoning_summary = "auto"
model_verbosity = "low"
model_auto_compact_token_limit = 64000Any key can also be overridden for a single run. The advanced configuration page documents -c and --config for arbitrary keys, with values parsed as TOML, and profile files loaded with --profile that overlay ~/.codex/<profile-name>.config.toml on the main file.
··········
CODEX MAX_OUTPUT_TOKENS: WHAT OPENAI DOCUMENTS AND WHAT USERS REPORT.
The API behavior is documented in detail. The Codex cases are mostly open bug reports, and none of them has an official explanation as of November 28, 2026.
........
Point | Status | Where it comes from |
Reasoning tokens count toward max_output_tokens | Documented | OpenAI reasoning guide; OpenAI support on the developer forum |
Response can be incomplete before any visible text | Documented | OpenAI reasoning guide |
Reserve at least 25,000 tokens when experimenting | Documented | OpenAI reasoning guide |
A Codex setting for max_output_tokens | Not documented | Codex configuration pages list none |
Remote compaction failing with exactly 128,000 output tokens on Windows | Reported, open | GitHub issue #60652 (Codex app 26.1103.7773.0, GPT-6 Luna Max) |
codex exec with structured output failing on the first call | Reported, open | GitHub issue #58728 (Codex 0.163 and 0.166 alpha builds, macOS, GPT-6.1 Sol) |
Whitespace loop in function-call arguments using the whole budget | Reported, unconfirmed | OpenAI developer forum (GPT-6 Astra, low effort, about 128,000 tokens) |
........
The compaction report is the most specific. Its author found that the failed compaction call used exactly 128,000 output tokens against about 248,000 input tokens, and that switching the same session to GPT-6.1 Sol Ultra let the stalled goal continue. The author was careful to add that a single successful switch does not prove the model change fixes the underlying bug, and no maintainer has replied on the issue. The structured-output report is less clear: a contributor who examined the Codex diagnostics wrote that the current output cannot tell context exhaustion apart from an output-budget problem.
··········
PREVENTING MAX_OUTPUT_TOKENS STOPS AFTER CODEX AND MODEL UPDATES.
New models and new Codex releases change both the default reasoning levels and the wording of errors, so the same workflow can start failing without any change on your side. For API code, log status, incomplete_details and the usage block on every response, and alert when output_tokens reaches the configured limit. For automation built on Codex output, match both the old prefixed text and the new unprefixed one, as the NeMo Gym maintainers had to do after Codex 0.163.0. After switching to a model with a higher default effort, re-test long tasks before relying on them in scripts or CI.
··········
OPENAI CODEX AND RESPONSES API MAX_OUTPUT_TOKENS: CONCLUSIONS.
Every form of the message points to the same event, a model that reached its output ceiling with reasoning tokens filling most of it. In the Responses API the fix is documented and quick, with a larger max_output_tokens value, at least 25,000 tokens as a starting point, a lower reasoning effort and a status check before reading the text. In Codex, where no documented setting raises the cap, lower effort, smaller tasks, leaner sessions and earlier compaction are the available controls. The compaction failure in the Windows app and the codex exec structured-output failure remain open issues with no official cause or fix as of November 28, 2026, and the only workaround on record for the first one, a model switch, comes from a single user.
··········
FOLLOW US FOR MORE.
·····
DATA STUDIOS
·····
datastudios.org




