openclaw - 💡(How to fix) Fix Embedded agent auto-compaction retries without reducing 873k-token Paperclip prompt [1 comments, 2 participants]

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…
GitHub stats
openclaw/openclaw#75740Fetched 2026-05-02 05:30:56
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Author
Timeline (top)
commented ×1

A long-running embedded/Paperclip agent session reached context overflow, auto-compaction retried three times, but the estimated prompt size did not decrease at all. The run remained at ~873k estimated prompt tokens against a ~242k prompt budget.

This looks like auto-compaction reporting attempts without actually reducing the selected prompt window for this session shape.

Error Message

[context-overflow-diag] sessionKey=agent:roi-ceo:paperclip provider=openai-codex/gpt-5.5 source=promptError messages=49 sessionFile=/home/coolmann/.openclaw/agents/roi-ceo/sessions/9bbbe46d-d3af-486f-9f63-92b711c60d3d.jsonl diagId=ovf-mon4azsa-YdtnzQ compactionAttempts=1 observedTokens=unknown error=Context overflow: prompt too large for the model (precheck). [context-overflow-diag] sessionKey=agent:roi-ceo:paperclip provider=openai-codex/gpt-5.5 source=promptError messages=49 sessionFile=/home/coolmann/.openclaw/agents/roi-ceo/sessions/9bbbe46d-d3af-486f-9f63-92b711c60d3d.jsonl diagId=ovf-mon4b3l8-X2J3QA compactionAttempts=2 observedTokens=unknown error=Context overflow: prompt too large for the model (precheck). [context-overflow-diag] sessionKey=agent:roi-ceo:paperclip provider=openai-codex/gpt-5.5 source=promptError messages=49 sessionFile=/home/coolmann/.openclaw/agents/roi-ceo/sessions/9bbbe46d-d3af-486f-9f63-92b711c60d3d.jsonl diagId=ovf-mon4b7eg-Bk-OzQ compactionAttempts=3 observedTokens=unknown error=Context overflow: prompt too large for the model (precheck). 3. The run fails once with a clear actionable error instead of retrying identical oversized prompts.

Root Cause

A long-running embedded/Paperclip agent session reached context overflow, auto-compaction retried three times, but the estimated prompt size did not decrease at all. The run remained at ~873k estimated prompt tokens against a ~242k prompt budget.

This looks like auto-compaction reporting attempts without actually reducing the selected prompt window for this session shape.

Fix Action

Fix / Workaround

Operational workaround

That is a workaround, not a root-cause fix.

Code Example

[context-overflow-diag] sessionKey=agent:roi-ceo:paperclip provider=openai-codex/gpt-5.5 source=promptError messages=49 sessionFile=/home/coolmann/.openclaw/agents/roi-ceo/sessions/9bbbe46d-d3af-486f-9f63-92b711c60d3d.jsonl diagId=ovf-mon4azsa-YdtnzQ compactionAttempts=1 observedTokens=unknown error=Context overflow: prompt too large for the model (precheck).
context overflow detected (attempt 2/3); attempting auto-compaction for openai-codex/gpt-5.5
[context-overflow-precheck] sessionKey=agent:roi-ceo:paperclip provider=openai-codex/gpt-5.5 route=compact_only estimatedPromptTokens=873084 promptBudgetBeforeReserve=242144 overflowTokens=630940 toolResultReducibleChars=0 reserveTokens=20000 effectiveReserveTokens=20000 sessionFile=/home/coolmann/.openclaw/agents/roi-ceo/sessions/9bbbe46d-d3af-486f-9f63-92b711c60d3d.jsonl
[context-overflow-diag] sessionKey=agent:roi-ceo:paperclip provider=openai-codex/gpt-5.5 source=promptError messages=49 sessionFile=/home/coolmann/.openclaw/agents/roi-ceo/sessions/9bbbe46d-d3af-486f-9f63-92b711c60d3d.jsonl diagId=ovf-mon4b3l8-X2J3QA compactionAttempts=2 observedTokens=unknown error=Context overflow: prompt too large for the model (precheck).
context overflow detected (attempt 3/3); attempting auto-compaction for openai-codex/gpt-5.5
[context-overflow-precheck] sessionKey=agent:roi-ceo:paperclip provider=openai-codex/gpt-5.5 route=compact_only estimatedPromptTokens=873084 promptBudgetBeforeReserve=242144 overflowTokens=630940 toolResultReducibleChars=0 reserveTokens=20000 effectiveReserveTokens=20000 sessionFile=/home/coolmann/.openclaw/agents/roi-ceo/sessions/9bbbe46d-d3af-486f-9f63-92b711c60d3d.jsonl
[context-overflow-diag] sessionKey=agent:roi-ceo:paperclip provider=openai-codex/gpt-5.5 source=promptError messages=49 sessionFile=/home/coolmann/.openclaw/agents/roi-ceo/sessions/9bbbe46d-d3af-486f-9f63-92b711c60d3d.jsonl diagId=ovf-mon4b7eg-Bk-OzQ compactionAttempts=3 observedTokens=unknown error=Context overflow: prompt too large for the model (precheck).

---

size_bytes=17248811
lines=11546
roles={'session': 1, 'model_change': 1, 'thinking_level_change': 1, 'custom': 2252, 'user': 2272, 'assistant': 4687, 'toolResult': 2332}

---

estimatedPromptTokens=873084
promptBudgetBeforeReserve=242144
overflowTokens=630940
toolResultReducibleChars=0

---

~/.openclaw/agents/roi-ceo/sessions/archive-context-overflow-20260501/9bbbe46d-d3af-486f-9f63-92b711c60d3d.jsonl
RAW_BUFFERClick to expand / collapse

Summary

A long-running embedded/Paperclip agent session reached context overflow, auto-compaction retried three times, but the estimated prompt size did not decrease at all. The run remained at ~873k estimated prompt tokens against a ~242k prompt budget.

This looks like auto-compaction reporting attempts without actually reducing the selected prompt window for this session shape.

Environment

  • OpenClaw: 2026.4.29 (a448042)
  • Provider/model: openai-codex/gpt-5.5
  • Session key: agent:roi-ceo:paperclip
  • Node: v22.22.2
  • OS: Linux x64

Log excerpt

[context-overflow-diag] sessionKey=agent:roi-ceo:paperclip provider=openai-codex/gpt-5.5 source=promptError messages=49 sessionFile=/home/coolmann/.openclaw/agents/roi-ceo/sessions/9bbbe46d-d3af-486f-9f63-92b711c60d3d.jsonl diagId=ovf-mon4azsa-YdtnzQ compactionAttempts=1 observedTokens=unknown error=Context overflow: prompt too large for the model (precheck).
context overflow detected (attempt 2/3); attempting auto-compaction for openai-codex/gpt-5.5
[context-overflow-precheck] sessionKey=agent:roi-ceo:paperclip provider=openai-codex/gpt-5.5 route=compact_only estimatedPromptTokens=873084 promptBudgetBeforeReserve=242144 overflowTokens=630940 toolResultReducibleChars=0 reserveTokens=20000 effectiveReserveTokens=20000 sessionFile=/home/coolmann/.openclaw/agents/roi-ceo/sessions/9bbbe46d-d3af-486f-9f63-92b711c60d3d.jsonl
[context-overflow-diag] sessionKey=agent:roi-ceo:paperclip provider=openai-codex/gpt-5.5 source=promptError messages=49 sessionFile=/home/coolmann/.openclaw/agents/roi-ceo/sessions/9bbbe46d-d3af-486f-9f63-92b711c60d3d.jsonl diagId=ovf-mon4b3l8-X2J3QA compactionAttempts=2 observedTokens=unknown error=Context overflow: prompt too large for the model (precheck).
context overflow detected (attempt 3/3); attempting auto-compaction for openai-codex/gpt-5.5
[context-overflow-precheck] sessionKey=agent:roi-ceo:paperclip provider=openai-codex/gpt-5.5 route=compact_only estimatedPromptTokens=873084 promptBudgetBeforeReserve=242144 overflowTokens=630940 toolResultReducibleChars=0 reserveTokens=20000 effectiveReserveTokens=20000 sessionFile=/home/coolmann/.openclaw/agents/roi-ceo/sessions/9bbbe46d-d3af-486f-9f63-92b711c60d3d.jsonl
[context-overflow-diag] sessionKey=agent:roi-ceo:paperclip provider=openai-codex/gpt-5.5 source=promptError messages=49 sessionFile=/home/coolmann/.openclaw/agents/roi-ceo/sessions/9bbbe46d-d3af-486f-9f63-92b711c60d3d.jsonl diagId=ovf-mon4b7eg-Bk-OzQ compactionAttempts=3 observedTokens=unknown error=Context overflow: prompt too large for the model (precheck).

Session file shape

Local inspection of the JSONL session file showed:

size_bytes=17248811
lines=11546
roles={'session': 1, 'model_change': 1, 'thinking_level_change': 1, 'custom': 2252, 'user': 2272, 'assistant': 4687, 'toolResult': 2332}

Largest individual events were only around 20k chars, and the recent tail showed many repeated medium-sized wake/prompt/assistant/tool events, e.g. user events around ~2.4k chars and assistant events around ~1-3k chars.

So this was not one huge reducible tool result. It was accumulated conversation/session history that eventually made the selected prompt window enormous.

Expected behavior

When auto-compaction is attempted after a precheck overflow, one of these should happen:

  1. The selected prompt window is reduced below budget.
  2. The old session history is summarized/rotated/truncated according to policy.
  3. The run fails once with a clear actionable error instead of retrying identical oversized prompts.

Actual behavior

Auto-compaction attempted three times, but the next precheck still reported the same estimated prompt size:

estimatedPromptTokens=873084
promptBudgetBeforeReserve=242144
overflowTokens=630940
toolResultReducibleChars=0

Operational workaround

I archived the bloated local session file and replaced the active file with an empty one so the agent can start fresh:

~/.openclaw/agents/roi-ceo/sessions/archive-context-overflow-20260501/9bbbe46d-d3af-486f-9f63-92b711c60d3d.jsonl

That is a workaround, not a root-cause fix.

Impact

Long-running embedded/Paperclip agents can accumulate enough session history to become unrecoverable by normal auto-compaction. The logs imply compaction is happening, but no effective reduction occurs, which makes the failure hard to reason about operationally.

extent analysis

TL;DR

The issue can be temporarily resolved by archiving the bloated local session file and replacing it with an empty one, allowing the agent to start fresh.

Guidance

  • Investigate the session history to understand why the accumulated conversation history is not being effectively reduced by auto-compaction.
  • Review the auto-compaction policy to ensure it is correctly configured to summarize, rotate, or truncate the session history.
  • Consider implementing a mechanism to monitor and limit the size of the session history to prevent similar issues in the future.
  • Analyze the logs to determine why the toolResultReducibleChars is reported as 0, indicating no reducible characters were found.

Example

No code snippet is provided as the issue is related to the configuration and behavior of the auto-compaction mechanism.

Notes

The provided workaround is temporary and does not address the root cause of the issue. A permanent fix would require identifying and resolving the issue with the auto-compaction mechanism.

Recommendation

Apply the workaround of archiving the bloated local session file and replacing it with an empty one, as it allows the agent to start fresh and resume operation. However, this should be followed by a thorough investigation into the auto-compaction mechanism to prevent similar issues in the future.

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

When auto-compaction is attempted after a precheck overflow, one of these should happen:

  1. The selected prompt window is reduced below budget.
  2. The old session history is summarized/rotated/truncated according to policy.
  3. The run fails once with a clear actionable error instead of retrying identical oversized prompts.

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 Embedded agent auto-compaction retries without reducing 873k-token Paperclip prompt [1 comments, 2 participants]