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)
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-d269e97aee50started 11 seconds after the one above (49.9 MB), suggesting duplicate session spawn
Expected behaviour
- 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.
- 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.
- Repeatedly resubmitting a near-identical cached context with no measurable progress should be detectable and should trip a circuit breaker.
- An
unauthorizedtoken-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.
2 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
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:
The circuit breaker can then combine hard limits with a no-progress detector:
next_actionor goal path;On trip, it should write a resumable stop artifact before terminating:
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:
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.