You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remote compaction v2 can loop: input tokens grow after each compaction #59534
In a long thread, remote compaction v2 completed successfully (exactly one compaction output item), but the next request was larger than the one before
compaction:
before compaction: 244,352 input tokens
after compaction: 272,173
after the next compaction: 292,503
after the next compaction: 312,153
model_context_window was 258,400. Each compacted event wrote a replacement_history of 30 items / about 127 KB (roughly 30k tokens), but the
following request's input_tokens stayed at 272k+, so the old context appears
to still be in the request. Every cycle added about 20k tokens and immediately
re-triggered compaction; the thread compacted 37 times in under an hour and
only stopped when the turn was aborted.
Expected
After a successful remote compaction, the next request should use the compacted
replacement history, so its input tokens drop (to roughly the replacement
history's size) and auto-compaction does not fire again immediately.
Actual
The next request is larger than the request before compaction, and compaction
loops.
Additional context
Codex version: 0.166.0.
No errors were returned by the endpoint; every compaction produced exactly one compaction item.
The compacted rollout event contains the expected replacement_history, but
the next request's token count does not reflect it.
model_context_window is 258,400; after each compaction the reported input is
above that window (272k, 292k, 312k), yet the requests still complete.
I can provide a minimal reproduction with a local mock server if useful.
The local mock you offered would be useful here: make compaction return a tiny, unmistakable replacement history, then assert that the next model request contains that replacement and excludes the old messages. Capture message counts and redacted content hashes alongside the reported token count. That separates a stale usage counter from failure to replace the actual request context, and lets the repeated-compaction case be tested without another hour of live model calls.
I have a closely related sanitized reproduction from a long-running Codex Desktop thread.
Environment:
Model: gpt-6-astra
Reported context window: 258,400 tokens
Observed: 2026-11-16 (client/runtime version was not captured)
Trace evidence:
The affected turn ran for about 71 minutes and emitted 27 compaction events across 46 command executions before interruption.
The latest compaction checkpoint contained 200 replacement-history items: 183 user messages, 15 developer messages, one additional_tools item, and one compaction item.
The serialized replacement history was approximately 70.5 MB.
Several retained user messages contained inline input_image payloads between 2 MB and 7 MB each.
The first request after compaction still reported 242,062 input tokens against the 258,400-token context window.
The full local rollout was approximately 11 GB and contained 248 compacted records.
The same turn then repeated repository-status and conflict-checking steps without reaching a durable state transition. No compaction endpoint error was visible; the task was eventually interrupted.
This appears consistent with a successful compaction that does not reduce the effective request context enough, possibly because retained history/media or token accounting still reflects the pre-compaction payload.
Could the compaction path validate both the serialized request and the model-visible item set after installation? Useful regression checks would be:
the first post-compaction request contains the new replacement history;
superseded large items and image payloads are absent or bounded;
input tokens and serialized bytes decrease materially after compaction;
repeated compactions with no reduction trip a bounded no-progress guard.
No private prompts, project paths, raw rollout data, or images are attached.
Activity
Zyph3rKeaton commentedon Nov 6, 2026
The local mock you offered would be useful here: make compaction return a tiny, unmistakable replacement history, then assert that the next model request contains that replacement and excludes the old messages. Capture message counts and redacted content hashes alongside the reported token count. That separates a stale usage counter from failure to replace the actual request context, and lets the repeated-compaction case be tested without another hour of live model calls.
SkyNet-T-800 commentedon Nov 16, 2026
I have a closely related sanitized reproduction from a long-running Codex Desktop thread.
Environment:
Trace evidence:
The same turn then repeated repository-status and conflict-checking steps without reaching a durable state transition. No compaction endpoint error was visible; the task was eventually interrupted.
This appears consistent with a successful compaction that does not reduce the effective request context enough, possibly because retained history/media or token accounting still reflects the pre-compaction payload.
Could the compaction path validate both the serialized request and the model-visible item set after installation? Useful regression checks would be:
No private prompts, project paths, raw rollout data, or images are attached.