Skip to content

Single turn issues 58 sequential exec calls, consuming 4.17M input tokens (34% of session) #53019

Open

Description

@mikeMigUelSg

What version of the Codex App are you using (From “About Codex” dialog)?

26.1007.21159

What subscription do you have?

ChatGPT Pro

What platform is your computer?

Darwin 24.6.0 arm64 arm

What issue are you seeing?

Summary

A session with 13 short user prompts produced 154 API calls and 12,251,371 total tokens — averaging ~940k tokens per user prompt.

One turn alone issued 58 API calls and consumed 4,172,193 input tokens: 34% of the entire session.

Token breakdown (from the local rollout)

Metric Value
Total tokens 12,251,371
Input 12,194,332
Cached input 11,675,392 (95.3%)
Output 57,039 (0.47%)
API calls 154
Mean context per call 79,184
Peak context 231,898
Compactions 1

Cost per turn, worst first:

Calls Input tokens Prompt
58 4,172,193 (attachment follow-up)
22 1,653,151 a 7-word correction
26 1,546,383 (follow-up)
6 984,020 "search recent forums"
1 131,555 "what do I do??"
1 16,717 "test"

The two single-call turns are included deliberately: the same agent, in the same context, answered some prompts in one round-trip.

This is not an output-size problem

All 139 tool outputs across the whole session total 789 kB ≈ 202k tokens — 1.7% of 12.25M. The model was already passing max_output_tokens of 20, 100, 200 and 350 per call.

The cost is 58 round-trips × ~72k of resent conversation, not large payloads. This matters because the obvious mitigation, tool_output_token_limit, does not address it.

The model abandoned batching mid-turn

Calls 1–12 of the expensive turn correctly batch several tools.exec_command invocations into a single Promise.allSettled([...]). From call 22 to 58 it switched to one command per call and never went back.

The base system prompt asks for parallelisation ("operations that may not parallelize cleanly, can be sequential" — i.e. sequential is the exception). The same ~58 operations, batched as in the opening calls, would have been roughly 15 round-trips and ~1M tokens instead of 4.17M.

What the 58 calls were doing

  • ~25 Python heredocs and sqlite queries against VS Code globalStorage and Code/logs/, several re-reading the same log directory with slightly different scripts (calls 34, 35, 36, 49, 50, 51)
  • 9 web searches (forums, GitHub issues, config docs)
  • kill <pid>, osascript ... to quit on VS Code, open -a 'Visual Studio Code', plus a 30-iteration wait loop for process exit

Expected vs actual

Expected: a turn following a short prompt stays bounded, or batches independent read-only commands as the system prompt instructs.

Actual: 58 sequential round-trips with no ceiling, repeated near-identical reads of the same directory, and no point at which the loop yields back to the user.

Relation to #30054

#30054 (closed as completed on 2026-08-31) described the same shape on an earlier build: a model_needs_follow_up loop, 23 sampling events within one turn, 100–200k tokens per turn.

This report is the same failure mode at roughly 20× the scale — 58 round-trips and 4,172,193 tokens in a single turn on 26.1007.21159 — which suggests either that the earlier fix did not hold or that it has regressed.

Suggested mitigations

  1. A per-turn round-trip budget that yields back to the user when exceeded.
  2. Surface cumulative turn cost in the UI. The context-window indicator shows occupancy, which hid this entirely — context stayed around 72k while the turn spent 4.17M.
  3. Re-anchor the batching instruction during long turns, since adherence decayed after roughly 12 calls.

Environment

  • codex-cli 0.162.0-alpha.17.2
  • VS Code extension openai.chatgpt-26.1007.21434
  • VS Code 1.140.0

Per-turn figures come from the turn_token_usage fields of the token_usage_record entries in the local rollout file. Happy to supply the thread ID privately.

What steps can reproduce the bug?

Not deterministically reproducible, but the conditions were consistent across the three expensive turns in this session:

  1. Start a session in the Codex VS Code extension on macOS.
    1. Give a short, open-ended diagnostic prompt that has no clear stopping condition — e.g. "search whether this is normal", or a brief correction such as "that isn't true, it started recently".
    1. Let the turn run without interrupting.
      Observed: the model begins an open-ended investigation and issues dozens of sequential exec round-trips in that single turn — log parsing, sqlite queries, web searches, process management — including repeated near-identical reads of the same directory. It batched commands into Promise.allSettled for the first ~12 calls, then switched to one command per call for the remaining ~36 and never resumed batching.

The turn does not yield back to the user at any point. In this session that produced 58 round-trips and 4,172,193 input tokens from one prompt.

Measurement: per-turn figures were read from the local rollout JSONL by grouping token_usage_record entries on root_turn_id and taking the final turn_token_usage for each. Session id available on request — omitted here since the issue is public.

What is the expected behavior?

Not deterministically reproducible, but the conditions were consistent across the three expensive turns in this session.

Steps:

  • Start a session in the Codex VS Code extension on macOS.
  • Give a short, open-ended diagnostic prompt with no clear stopping condition — e.g. "search whether this is normal", or a brief correction such as "that isn't true, it started recently".
  • Let the turn run without interrupting.

Observed: the model begins an open-ended investigation and issues dozens of sequential exec round-trips within that single turn — log parsing, sqlite queries, web searches, process management — including repeated near-identical reads of the same directory. It batched commands into Promise.allSettled for the first ~12 calls, then switched to one command per call for the remaining ~36 and never resumed batching. The turn never yields back to the user.

In this session that produced 58 round-trips and 4,172,193 input tokens from a single prompt.

Measurement: per-turn figures were read from the local rollout JSONL by grouping token_usage_record entries on root_turn_id and taking the final turn_token_usage for each. Session id available on request — omitted here since the issue is public.

Additional information

No response

Activity

  1. added
    app
    on Oct 11, 2026
  2. added
    bug
    extension
    model-behavior
    rate-limits
    on Oct 11, 2026
  3. mikeMigUelSg commented on Oct 11, 2026

    @mikeMigUelSg
    Author

    Submitted via /feedback, so the full session log is already uploaded on your side. Local confirmation:

    codex_feedback  feedback event uploaded to Sentry
    thread_id=01a1285d-9366-7101-b72f-037a12ecd081
    uploaded_attachments=12  attachments_failed=false  elapsed_ms=1249
    

    Session / thread ID: 01a1285d-9366-7101-b72f-037a12ecd081
    Worst turn: 01a1286f-5dbf-79b1-9ab5-fbf99897b052 — 58 round-trips, 4,172,193 input tokens.

    Posting the IDs here per the requests in #30002 and #28879.

    To locate the turn in the attached rollout: group token_usage_record entries by root_turn_id and take the last turn_token_usage of each. The 58 custom_tool_call entries under that turn id show the Promise.allSettled batching in the first ~12 calls and the one-command-per-call pattern from call 22 onward.

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

    appbugextensionmodel-behaviorrate-limits

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions