Skip to content

Repeated tool-loop context overflows cause successive auto-compactions after successful compaction (v2026.5.5) #78562

@EthanSK

Description

@EthanSK

Summary

In OpenClaw 2026.5.5, a tool-heavy Telegram session can enter repeated auto-compaction loops after browser/log/memory tool output. Each compaction succeeds, but the next tool-loop prompt can immediately hit context overflow again, so the user sees the assistant repeatedly “compacting context over and over” inside the same live task.

This is not the older single 900s compaction-timeout failure. In the current incident, compactions completed in roughly 30–65 seconds, but repeated several times within minutes.

Environment

  • OpenClaw: 2026.5.5 (b1abf9d)
  • Runtime: embedded Pi / OpenClaw Pi Default
  • Model: openai-codex/gpt-5.5
  • Channel/session: Telegram direct, default account
  • Platform: macOS arm64 / Mac mini
  • Context pruning: cache-ttl, ttl: 1h
  • Compaction config: mode: safeguard, reserveTokensFloor: 30000

Observed evidence

Session status during the incident:

  • Context: 145k/272k (53%)
  • Compactions: 7
  • Queue: steer depth 0

Recent same-session log sequence:

2026-05-06T16:44:28.202Z [context-overflow-diag] sessionKey=agent:main:telegram:default:direct:<telegram-peer> ... messages=171 ... error=Context overflow: estimated context size exceeds safe threshold during tool loop.
2026-05-06T16:44:28.203Z context overflow detected (attempt 1/3); attempting auto-compaction for openai-codex/gpt-5.5
2026-05-06T16:45:32.677Z auto-compaction succeeded for openai-codex/gpt-5.5; retrying prompt

2026-05-06T16:49:47.993Z [context-overflow-diag] sessionKey=agent:main:telegram:default:direct:<telegram-peer> ... messages=74 ... compactionAttempts=1 ... error=Context overflow: estimated context size exceeds safe threshold during tool loop.
2026-05-06T16:49:47.994Z context overflow detected (attempt 2/3); attempting auto-compaction for openai-codex/gpt-5.5
2026-05-06T16:50:36.537Z auto-compaction succeeded for openai-codex/gpt-5.5; retrying prompt

2026-05-06T16:58:39.489Z [context-overflow-diag] sessionKey=agent:main:telegram:default:direct:<telegram-peer> ... messages=96 ... error=Context overflow: estimated context size exceeds safe threshold during tool loop.
2026-05-06T16:58:39.490Z context overflow detected (attempt 1/3); attempting auto-compaction for openai-codex/gpt-5.5
2026-05-06T16:59:39.005Z auto-compaction succeeded for openai-codex/gpt-5.5; retrying prompt

2026-05-06T17:00:16.214Z [context-overflow-diag] sessionKey=agent:main:telegram:default:direct:<telegram-peer> ... messages=29 ... compactionAttempts=1 ... error=Context overflow: estimated context size exceeds safe threshold during tool loop.
2026-05-06T17:00:16.215Z context overflow detected (attempt 2/3); attempting auto-compaction for openai-codex/gpt-5.5
2026-05-06T17:00:48.647Z auto-compaction succeeded for openai-codex/gpt-5.5; retrying prompt

A subagent in the same window showed the same shape:

2026-05-06T17:04:11.434Z [context-overflow-diag] sessionKey=agent:main:subagent:da38255f-6071-4c55-a4d8-3ba166bad7b9 ... messages=26 ... error=Context overflow: estimated context size exceeds safe threshold during tool loop.
2026-05-06T17:04:11.437Z context overflow detected (attempt 1/3); attempting auto-compaction for openai-codex/gpt-5.5
2026-05-06T17:04:39.935Z auto-compaction succeeded for openai-codex/gpt-5.5; retrying prompt
2026-05-06T17:06:34.501Z [context-overflow-diag] sessionKey=agent:main:subagent:da38255f-6071-4c55-a4d8-3ba166bad7b9 ... messages=34 ... compactionAttempts=1 ... error=Context overflow: estimated context size exceeds safe threshold during tool loop.
2026-05-06T17:07:05.531Z auto-compaction succeeded for openai-codex/gpt-5.5; retrying prompt

Trigger context

The live task was browser-heavy:

  • Several browser.snapshot calls against Vue seat-map pages produced very large accessibility trees.
  • The same session also read memory/startup files and ran runtime diagnostics.
  • OpenClaw repeatedly compacted after Context overflow ... during tool loop, not because of a single huge user message.

Expected behavior

After successful auto-compaction, OpenClaw should avoid immediately re-entering another compaction loop for the same task/tool-loop pattern. Possible expected mitigations:

  • more aggressive post-compaction tool-result truncation when the overflow source is tool output;
  • a cooldown/escalation path after N successful-but-insufficient compactions in the same run/session;
  • force a smaller replay window / compact_then_truncate after repeated tool-loop overflows;
  • surface a clearer diagnostic or user-facing notice that the session is stuck in repeated overflow recovery.

Actual behavior

Compaction succeeds, the prompt retries, then another large tool-loop replay can trigger another context overflow within minutes. From the user perspective, the assistant keeps “compacting context over and over” and the actual task latency becomes confusing/noisy.

Related issues

This appears related to, but narrower/different from:

The distinction here: compaction is succeeding quickly, but repeated tool-loop overflows still cause successive compactions in normal browser/tool-heavy work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions