Skip to content

[code-mode] outer exec truncates aggregated results despite higher nested budgets, causing token waste and retry churn #33402

Open

Description

@armapew

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?

  1. Start a Codex app-server session using code mode/programmatic tool calling.
  2. Ask Codex to inspect multiple files or run multiple searches in parallel, where the combined output exceeds 10,000 tokens.
  3. 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);
  1. Do not add an outer // @exec pragma.
  2. Inspect the resulting custom_tool_call_output in the rollout JSONL.
  3. 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: ...)
  1. 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_tokens pragma 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_tokens is 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

Activity

  1. added
    CLIIssues related to the Codex CLI
    app-serverIssues involving app server protocol or interfaces
    tool-callsIssues related to tool calling
    rate-limitsIssues related to rate limits, quotas, and token usage reporting
    on Jul 15, 2026
  2. regiedesk commented on Sep 12, 2026

    @regiedesk

    Confirmed this still reproduces on codex-cli 0.154.0, with gpt-6-astra at low reasoning, and it can affect bundled Skill instructions.

    I tested the bundled Documents Skill (documents package 26.905.11957). Its root SKILL.md is 5,410 words / 40,510 Unicode characters / 40,679 bytes. In two independent runs, Codex read that Skill root plus one small Markdown source in the same aggregated exec call. The nested read requested max_output_tokens: 12000.

    In both runs:

    • the underlying commands completed and the rollout retained their full stdout;
    • the model-visible custom_tool_call_output reported original token count: 12024;
    • exactly …2024 tokens truncated… was inserted, consistent with a 10,000-token outer result cap;
    • the omitted Skill segment was not subsequently reread in chunks.

    So this reproduced 2/2 on 0.154.0. The evidence points to the outer aggregated exec result limit rather than to a Skill-loader truncation.

    No quality regression or context compaction was observed in these short test tasks—the model still completed correctly—but this creates a concrete risk when correctness depends on instructions located in the omitted portion of a long Skill root.

    This also intersects with the newer GPT-6 Astra guidance recommending minimal router-style roots / progressive disclosure for multi-workflow Skills. Either reducing large bundled Skill roots or making the aggregate-output path propagate/raise the outer budget (or explicitly recover omitted chunks) would avoid silently reasoning from partial Skill instructions.

    I intentionally did not modify the bundled Skill/cache locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLIapp-serverIssues involving app server protocol or interfacesbugSomething isn't workingrate-limitsIssues related to rate limits, quotas, and token usage reportingtool-callsIssues related to tool calling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions