[code-mode] outer `exec` truncates aggregated results despite higher nested budgets, causing token waste and retry churn
What version of Codex CLI is running?
0.144.3
What subscription do you have?
Pro
Which model were you using?
gpt-5.6-sol
What platform is your computer?
Linux 5.15.167.4-microsoft-standard-WSL2 x86_64 x86_64
What terminal emulator and version are you using (if applicable)?
WSL
What issue are you seeing?
When Codex uses the new code-mode/programmatic exec tool to compose multiple nested exec_command calls, each nested command can specify a large max_output_tokens value, but the combined result is still truncated by a separate 10,000-token outer exec limit.
In my session, Codex generated four parallel exec_command calls with limits between 12,000 and 30,000 tokens, then emitted their results using:
for (const x of r) text(x);
The combined output contained 13,343 tokens, but the resulting custom_tool_call_output reported:
Warning: truncated output (original token count: 13343)
The nested limits do not propagate to the surrounding programmatic exec. Avoiding the truncation requires a separate first-line pragma:
// @exec: {"max_output_tokens": 20000}
Codex generated the tool call itself but omitted this pragma, despite deliberately assigning higher budgets to the nested commands. It also serialized complete result objects with text(x) instead of emitting only text(x.output), increasing the aggregate token count.
This can discard repository documentation, search results, or command output that Codex explicitly requested and may cause it to reason from incomplete information. The user may not notice beyond the truncation warning in the tool result, and there is currently no apparent configuration setting for changing the outer code-mode default.
What steps can reproduce the bug?
- Start a Codex app-server session using code mode/programmatic tool calling.
- Ask Codex to inspect multiple files or run multiple searches in parallel, where the combined output exceeds 10,000 tokens.
- Observe a generated tool call similar to:
const results = await Promise.all([
tools.exec_command({
cmd: "seq 1 7000",
max_output_tokens: 20000
}),
tools.exec_command({
cmd: "seq 7001 14000",
max_output_tokens: 20000
})
]);
for (const result of results) text(result);
- Do not add an outer
// @execpragma. - Inspect the resulting
custom_tool_call_outputin the rollout JSONL. - The nested commands allow more than 10,000 tokens, but their combined result is truncated to the outer default and contains a warning such as:
Warning: truncated output (original token count: ...)
- Repeat with this first line:
// @exec: {"max_output_tokens": 30000}
The outer result is no longer truncated at 10,000 tokens, assuming it remains below the requested budget.
Observed with:
codex-cli 0.144.3
model: gpt-5.6-sol
interface: app-server
What is the expected behavior?
Codex should not unexpectedly discard aggregated output when it generated nested calls with explicit output budgets larger than the outer default.
Any of the following would address the problem:
- Codex reliably adds an outer
max_output_tokenspragma when aggregating potentially large nested results. - The outer budget is derived from the actual or requested nested output budgets, subject to a documented safety cap.
- The default outer code-mode limit is configurable.
max_output_tokensis exposed as a normal structured parameter instead of only through a source-code pragma.- Generated aggregation emits only necessary fields such as
result.output, avoiding unnecessary JSON serialization. - If truncation still occurs, the warning explicitly identifies the outer code-mode aggregate limit and explains how to raise it.
At minimum, the model-generated call and the tool contract should be aligned so that Codex does not request large nested outputs and then unintentionally truncate them at a separate outer layer.
Additional information
_No response_