openclaw - 💡(How to fix) Fix Codex native /compact completes, but status shows Compactions: 0 and stale token counts

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

  • Gateway logs only started codex app-server compaction.
  • /status reports Compactions: 0, because native Codex compaction is not counted as an OpenClaw-completed compaction.
  • User cannot tell whether /compact completed or failed from OpenClaw status.
  • Token counts diverge across sources:
    • openclaw status / sessions.json showed persisted totalTokens: 65,250 (65k/272k).
    • Live Codex app-server rollout token events around the same investigation showed much higher last_token_usage.total_tokens, including 115,750 / 115,794 earlier and later 104k-110k.
    • The user-facing context/status line showed about 116k/272k, while CLI /status showed 53k/65k.
RAW_BUFFERClick to expand / collapse

OpenClaw 2026.5.28, Runtime: OpenAI Codex, Telegram direct session.

Repro

  1. In a Codex-backed Telegram direct session, grow context.
  2. Send /compact.
  3. Check /status after the "Codex compaction started" system event.
  4. Compare /status with the live context/token line shown to the user/UI during later turns.

Expected

  • /status should show native Codex compaction as pending/completed, or otherwise make clear that native completion is not tracked.
  • Once Codex emits context_compacted, OpenClaw should bridge the result into session state/status, including completion/failure diagnostics.
  • Token counts shown by /status, session list/UI, and live Codex app-server usage should not materially disagree without indicating which source is being displayed.

Actual

  • Gateway logs only started codex app-server compaction.
  • /status reports Compactions: 0, because native Codex compaction is not counted as an OpenClaw-completed compaction.
  • User cannot tell whether /compact completed or failed from OpenClaw status.
  • Token counts diverge across sources:
    • openclaw status / sessions.json showed persisted totalTokens: 65,250 (65k/272k).
    • Live Codex app-server rollout token events around the same investigation showed much higher last_token_usage.total_tokens, including 115,750 / 115,794 earlier and later 104k-110k.
    • The user-facing context/status line showed about 116k/272k, while CLI /status showed 53k/65k.

Evidence From Local Run

Gateway starts:

  • 2026-05-31T17:23:03+03 started codex app-server compaction
  • 2026-05-31T17:35:31+03 started codex app-server compaction
  • 2026-05-31T18:06:12+03 started codex app-server compaction

Codex rollout completions:

  • 2026-05-31T17:23:36+03 context_compacted, last usage about 71,752 tokens.
  • 2026-05-31T17:36:03+03 context_compacted, last usage about 71,640 tokens.

Relevant local state/code observations:

  • sessions.json for agent:main:telegram:direct:6065935464 had compactionCount: 0.
  • sessions.json persisted totalTokens: 65,250 while live Codex rollout token events had moved beyond that.
  • compact-DWR7VG7G.js calls Codex app-server thread/compact/start and returns compacted:false, pending:true.
  • Runtime status code increments compactionCount only when result.ok && result.compacted && !codexNativeCompactionStarted.
  • The docs say Codex-backed agents start native compaction and OpenClaw does not wait for completion or record it as OpenClaw-completed compaction.

Likely Root Cause

OpenClaw starts native Codex compaction via thread/compact/start, but does not bridge Codex context_compacted / subsequent live token_count events back into sessions.json, compactionCount, or /status.

This makes /compact look failed or stuck even when Codex completed it, and it lets persisted status token counts drift from live Codex app-server token accounting.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Codex native /compact completes, but status shows Compactions: 0 and stale token counts