Skip to content

Unattended session ran 16.5h from one prompt: 7,395 requests, 4.2B tokens, no interrupt path, unrecoverable auth end (codex-cli 0.146.0) #37282

Open

Description

@dwbimstr

Summary

A single codex-cli session ran 16 h 30 m unattended after one initial prompt, issuing 7,395 model requests and consuming 4.2 billion tokens, until it terminated on an auth error. No further human input was given after the first 38 ms of the session. The session could not be steered or reattached while it ran, and could not be resumed afterwards.

The concerning part is not that a long task ran — it is that there is no observable ceiling, no unattended-runtime guard, and no way to reattach to or interrupt the loop once the launching terminal is gone.

Environment

codex-cli 0.146.0
OS macOS 15 (Darwin 25.5.0), Apple M3 Pro
Session ID 019fc8dc-2fbe-79b3-a361-67a6e6e37935
Rollout ~/.codex/sessions/2026/08/03/rollout-2026-08-03T13-21-41-019fc8dc-2fbe-79b3-a361-67a6e6e37935.jsonl (97,811,681 bytes)

Measured from the rollout

Session span: 2026-08-03T18:21:41.419Z → 2026-08-04T10:52:23.344Z = 16:30:41

All four user_message records arrived inside the first 38 ms (18:21:41.419 → 18:21:41.457) — that is the initial prompt payload, not four human turns. Time from the last human input to the last event: 16:30:41.

record type count
user_message 4 (all at t+0..38 ms)
agent_message 786
function_call 994
token_count (≈ model requests) 7,395

Final token_count payload:

{
  "total_token_usage": {
    "input_tokens": 4205410108,
    "cached_input_tokens": 4095808512,
    "cache_write_input_tokens": 0,
    "output_tokens": 9700286,
    "reasoning_output_tokens": 3483841,
    "total_tokens": 4215110394
  },
  "model_context_window": 258400
}

4,215,110,394 total tokens from one prompt. 97.4 % of input was cached, which is consistent with the same large context being resubmitted thousands of times rather than the task actually progressing.

agent_message records carry an author field shaped like a goal path ("/root/<goal>/<subgoal>"), i.e. the run had decomposed into a self-directed goal hierarchy that kept scheduling its own follow-up work.

Terminal state

The session ended on:

{
  "message": "Your access token could not be refreshed because you have since logged out or signed in to another account. Please sign in again.",
  "codex_error_info": "unauthorized"
}

This is the second half of the problem: the loop was not stopped by any budget, turn, or wall-clock limit — it was stopped by an auth refresh failure ~16.5 h in. Once in that state the session could not be resumed, and the work in progress was not recoverable through the CLI.

Scale across the same day

This was not an isolated session:

  • ~/.codex/sessions/2026/08/03/ — 80 rollout files, 8.4 GB total
  • 35 of those exceed 100 MB
  • Several individual rollouts are 190–207 MB
  • A sibling session 019fc8dc-5bbb-75c0-82b4-d269e97aee50 started 11 seconds after the one above (49.9 MB), suggesting duplicate session spawn

Expected behaviour

  1. An unattended run should have a bounded ceiling — max turns, max tokens, or max wall-clock — after which it pauses and asks, rather than continuing indefinitely.
  2. A running session should be reattachable/interruptible from another terminal. When the launching terminal is gone there is currently no supported way to inject input or stop the loop short of killing the process.
  3. Repeatedly resubmitting a near-identical cached context with no measurable progress should be detectable and should trip a circuit breaker.
  4. An unauthorized token-refresh failure should be recoverable — re-auth and resume — rather than stranding the session.

Actual behaviour

One prompt produced 16.5 h of unattended execution, 7,395 model requests and 4.2 B tokens, with no interrupt path, ending in an unrecoverable auth state.

Impact

The run exhausted the account quota. It also left the working tree in a partial state — many modified files and incomplete commits — because the loop was terminated mid-flight rather than at a checkpoint.

Notes

  • Happy to provide the rollout .jsonl (or extracts) to a maintainer; it is 97 MB and contains repository content, so I have not attached it here.
  • I have not been able to identify a reliable reproduction trigger. The signal I can offer is the shape: goal-path decomposition + very high cached-input ratio + no human input, sustained for hours.

Activity

  1. added
    bugSomething isn't working
    CLIIssues related to the Codex CLI
    subagentIssues involving subagents or multi-agent features
    sessionIssues involving session (thread) management, resuming, forking, naming, archiving
    rate-limitsIssues related to rate limits, quotas, and token usage reporting
    authIssues related to authentication and accounts
    on Aug 6, 2026
  2. leadingproblemsolver commented on Aug 6, 2026

    @leadingproblemsolver

    The guard probably needs to be based on progress receipts, not only static request/token/time ceilings. A fixed ceiling stops the damage, but it cannot distinguish a productive 6-hour migration from a 20-minute no-progress loop.

    I would make each autonomous continuation window emit a compact durable checkpoint such as:

    {
      "window": 17,
      "started_at": "...",
      "ended_at": "...",
      "requests": 120,
      "input_tokens": 68000000,
      "cached_input_ratio": 0.976,
      "workspace_before": "sha256:...",
      "workspace_after": "sha256:...",
      "new_commits": [],
      "tests_changed": false,
      "open_blockers": ["auth refresh failing"],
      "next_action": "retry the same review subgoal",
      "evidence": ["git status", "test report path", "artifact hashes"]
    }

    The circuit breaker can then combine hard limits with a no-progress detector:

    • request/token/wall-clock maximum;
    • N consecutive windows with unchanged workspace/artifact hashes;
    • repeated semantic-equivalent next_action or goal path;
    • high cached-input ratio plus no durable state change;
    • repeated tool-call sequence with no new verified output;
    • auth/credential transition while unattended.

    On trip, it should write a resumable stop artifact before terminating:

    PAUSED_NO_PROGRESS
    last verified repository state
    commands still running
    uncommitted paths
    completed vs merely attempted subgoals
    failed credential/account identity
    exact safe resume boundary
    

    That would address the final failure here too: re-authentication should attach to the durable stop artifact and verified workspace state, not require trusting the last natural-language agent summary.

    The important invariant is:

    Autonomous continuation requires fresh evidence of durable progress; model activity alone is not progress.

    I maintain a small local-first operational-state compiler using SQLite, source/content hashes, timelines and source-linked context packs: https://github.com/leadingproblemsolver/living-context-engine

    It is not a Codex runtime controller, but its evidence boundary may be useful for the checkpoint/stop artifact: generated summaries are retrieval aids, while filesystem/Git/test observations remain the authoritative state.

  3. Keesan12 commented on Sep 29, 2026

    @Keesan12

    The missing piece is a hard stop outside the model. Cap iterations and spend, restrict the writable paths, then require the repo test command before the run can claim success.

    I built MartinLoop. It is open source. A bounded version of this run would look like

    martin run "finish the blocked change" --verify "npm test" --allow-path src --budget-usd 5 --max-iterations 8

    If a live run is already going sideways, martin cancel --reason "no measurable progress" gives you an explicit stop record.

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 CLIauthIssues related to authentication and accountsbugSomething isn't workingrate-limitsIssues related to rate limits, quotas, and token usage reportingsessionIssues involving session (thread) management, resuming, forking, naming, archivingsubagentIssues involving subagents or multi-agent features

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions