[code-mode] outer `exec` truncates aggregated results despite higher nested budgets, causing token waste and retry churn
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- javascript, rust
- Domain
- cli, developer-experience, tooling
Research direction
Start by reproducing the code-mode programmatic exec flow with parallel nested exec_command calls, comparing aggregated output with and without the // @exec max_output_tokens pragma. Trace the outer budget and result serialization through the generated tool call and rollout JSONL; done means requested nested output is not unexpectedly discarded, or the truncation warning clearly identifies the outer limit and how to raise it.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.5k
- Avg merge
- 1m
- Merged PRs (30d)
- 1k
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openai/codex
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug CLI windows-os
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
macOS sandbox blocks hw.optional.arm64 sysctl, causing Flutter to misdetect Apple Silicon as x64 Openbug CLI sandbox
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug CLI TUI
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
CLI config enhancement skills
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
A-linter
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
oxc-project/oxc#26863 ·