openclaw - 💡(How to fix) Fix Codex app-server compaction times out in Telegram direct sessions; shows 272k window but /compact uses 200k and session becomes unrecoverable

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…

Long Telegram direct sessions backed by the Codex app-server can become unrecoverable when compaction is needed. The user-facing context/status view can report a larger window (158k/272k, 58%), but /compact runs against a smaller Codex-native window (158k/200k, 79%) and times out:

Compaction failed: timed out waiting for codex app-server compaction for <codex-thread-id> • Context 158k/200k (79%)

After this, ordinary Telegram messages may surface only the generic error:

Something went wrong while processing your request. Please try again, or use /new to start a fresh session.

Manual /compact works when done early in a fresh/small session. The failure appears once the Codex-backed native thread is large enough that compaction itself times out.

Error Message

  1. A long Telegram direct session reaches a size where normal status can show a context window like:

Root Cause

  • Use /new once the session is already broken.
  • Manually run /compact around 100k-120k/272k.
  • Treat 150k+/272k as danger territory.
  • Treat 158k/272k as already too late because /compact sees it as about 158k/200k.

Fix Action

Fix / Workaround

Current workaround, not a root fix:

Operational workaround:

Code Example

Compaction failed: timed out waiting for codex app-server compaction for <codex-thread-id>Context 158k/200k (79%)

---

Something went wrong while processing your request. Please try again, or use /new to start a fresh session.

---

OpenClaw 2026.5.19 (a185ca2)
codex-cli 0.125.0
Runtime: OpenAI Codex app-server
Main model: openai/gpt-5.5
Fallback model: openai/gpt-5.4
Channel: Telegram direct
Auth shape: OpenAI Codex OAuth
Gateway: systemd user service

---

Context: 158k/272k (58%)

---

Context 158k/200k (79%)

---

Compaction failed: timed out waiting for codex app-server compaction for <codex-thread-id>Context 158k/200k (79%)

---

Cache: 100% hit · 201k cached, 0 new
Context: 0/200k (0%)

---

{ "mode": "safeguard" }

---

{
  "mode": "safeguard",
  "reserveTokens": 24000,
  "keepRecentTokens": 40000,
  "reserveTokensFloor": 16000,
  "maxHistoryShare": 0.55,
  "customInstructions": "Preserve only durable state needed to continue safely: active tasks, user preferences, decisions, blockers, IDs, URLs, file paths, important commands/errors. Remove repetition, logs, casual chat, and stale debugging detail.",
  "identifierPolicy": "strict",
  "recentTurnsPreserve": 6
}

---

openclaw config get agents.defaults.compaction --json

---

{
  "mode": "safeguard",
  "reserveTokens": 24000,
  "keepRecentTokens": 40000,
  "reserveTokensFloor": 16000,
  "maxHistoryShare": 0.55,
  "customInstructions": "Preserve only durable state needed to continue safely: active tasks, user preferences, decisions, blockers, IDs, URLs, file paths, important commands/errors. Remove repetition, logs, casual chat, and stale debugging detail.",
  "identifierPolicy": "strict",
  "recentTurnsPreserve": 6
}
RAW_BUFFERClick to expand / collapse

Summary

Long Telegram direct sessions backed by the Codex app-server can become unrecoverable when compaction is needed. The user-facing context/status view can report a larger window (158k/272k, 58%), but /compact runs against a smaller Codex-native window (158k/200k, 79%) and times out:

Compaction failed: timed out waiting for codex app-server compaction for <codex-thread-id> • Context 158k/200k (79%)

After this, ordinary Telegram messages may surface only the generic error:

Something went wrong while processing your request. Please try again, or use /new to start a fresh session.

Manual /compact works when done early in a fresh/small session. The failure appears once the Codex-backed native thread is large enough that compaction itself times out.

Environment

OpenClaw 2026.5.19 (a185ca2)
codex-cli 0.125.0
Runtime: OpenAI Codex app-server
Main model: openai/gpt-5.5
Fallback model: openai/gpt-5.4
Channel: Telegram direct
Auth shape: OpenAI Codex OAuth
Gateway: systemd user service

Observed behavior

  1. A long Telegram direct session reaches a size where normal status can show a context window like:
Context: 158k/272k (58%)
  1. Running /compact reports the smaller Codex-native path/window:
Context 158k/200k (79%)
  1. Compaction times out:
Compaction failed: timed out waiting for codex app-server compaction for <codex-thread-id> • Context 158k/200k (79%)
  1. Normal requests then fail through the same chain and Telegram gets only the generic wrapper error.

  2. We also saw inconsistent token/cache accounting after compaction/failure/projection events, including a status-like output shaped like:

Cache: 100% hit · 201k cached, 0 new
Context: 0/200k (0%)

Expected behavior

One of these should happen:

  • OpenClaw/Codex should compact successfully before the session reaches the unrecoverable zone.
  • The user-facing context number should reflect the actual Codex compaction budget/window.
  • If compaction cannot be completed, OpenClaw should provide a specific actionable error rather than only the generic Telegram failure.
  • Ideally, automatic/system-triggered compaction should happen early enough that manual /new is not the only recovery.

What we tested

These hypotheses did not fix it:

  • Old custom compaction settings caused the issue.
  • Reducing agents.defaults.compaction to only:
{ "mode": "safeguard" }
  • Removing the entire agents.defaults.compaction block and using defaults.

Current workaround, not a root fix:

{
  "mode": "safeguard",
  "reserveTokens": 24000,
  "keepRecentTokens": 40000,
  "reserveTokensFloor": 16000,
  "maxHistoryShare": 0.55,
  "customInstructions": "Preserve only durable state needed to continue safely: active tasks, user preferences, decisions, blockers, IDs, URLs, file paths, important commands/errors. Remove repetition, logs, casual chat, and stale debugging detail.",
  "identifierPolicy": "strict",
  "recentTurnsPreserve": 6
}

Operational workaround:

  • Use /new once the session is already broken.
  • Manually run /compact around 100k-120k/272k.
  • Treat 150k+/272k as danger territory.
  • Treat 158k/272k as already too late because /compact sees it as about 158k/200k.

Sanitized config evidence

Command:

openclaw config get agents.defaults.compaction --json

Output:

{
  "mode": "safeguard",
  "reserveTokens": 24000,
  "keepRecentTokens": 40000,
  "reserveTokensFloor": 16000,
  "maxHistoryShare": 0.55,
  "customInstructions": "Preserve only durable state needed to continue safely: active tasks, user preferences, decisions, blockers, IDs, URLs, file paths, important commands/errors. Remove repetition, logs, casual chat, and stale debugging detail.",
  "identifierPolicy": "strict",
  "recentTurnsPreserve": 6
}

Notes

  • The explicit agents.defaults.compaction.model approach was previously tested and did not solve Codex app-server compaction, because Codex native compaction appears to ignore that OpenClaw override.
  • The full openclaw.json was separately sanitized locally; this issue only includes the relevant sanitized config excerpts.
  • Identifiers, email, Telegram user ID, OAuth/account identifiers, tokens, and local private paths have been redacted.

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…

FAQ

Expected behavior

One of these should happen:

  • OpenClaw/Codex should compact successfully before the session reaches the unrecoverable zone.
  • The user-facing context number should reflect the actual Codex compaction budget/window.
  • If compaction cannot be completed, OpenClaw should provide a specific actionable error rather than only the generic Telegram failure.
  • Ideally, automatic/system-triggered compaction should happen early enough that manual /new is not the only recovery.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING