openclaw - 💡(How to fix) Fix Session crashes with Context overflow when large Project Context is injected at session start [1 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#70618Fetched 2026-04-24 05:55:36
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Error Message

Session crashes with the error: Context overflow: estimated context size exceeds safe threshold during tool loop when a large Project Context file (MEMORY.md, ~50KB+) is injected at session startup.

Error Log

  1. Context estimation pre-check: Warn user/agent when estimated context is approaching overflow threshold before tool execution fails

Fix Action

Workaround

None ideal — users with large MEMORY.md / daily logs have no way to prevent this crash loop.


Reported via OpenClaw agent diagnostic (session diagnostics only, no user content)

Code Example

Context overflow: estimated context size exceeds safe threshold during tool loop.
--- GW log around crash ---
21:16:12 - 21:16:43  Concurrent chat.history and node.list calls
21:19:11  Last chat.send before crash (runId=94eeaa21)
21:20:27  [sessions/store] rotated session store file
21:21:37  [sessions/store] rotated session store file
21:21:37  [sessions/store] cleaned up old session store backups
21:21:45  [sessions/store] cleaned up old session store backups  (deleted: 1)
21:25:29  Session restored (after circuit breaker)
RAW_BUFFERClick to expand / collapse

Bug Description

Session crashes with the error: Context overflow: estimated context size exceeds safe threshold during tool loop when a large Project Context file (MEMORY.md, ~50KB+) is injected at session startup.

This also triggers aggressive session store rotation and cleanup, which can cause data loss.

Steps to Reproduce

  1. Start a new session
  2. System injects a large MEMORY.md (~50KB+) into Project Context
  3. Perform any tool calls (especially concurrent ones like sessions.list, chat.history, node.list) within the first few minutes
  4. Context grows beyond safe threshold → session crashes

Error Log

Context overflow: estimated context size exceeds safe threshold during tool loop.
--- GW log around crash ---
21:16:12 - 21:16:43  Concurrent chat.history and node.list calls
21:19:11  Last chat.send before crash (runId=94eeaa21)
21:20:27  [sessions/store] rotated session store file
21:21:37  [sessions/store] rotated session store file
21:21:37  [sessions/store] cleaned up old session store backups
21:21:45  [sessions/store] cleaned up old session store backups  (deleted: 1)
21:25:29  Session restored (after circuit breaker)

Expected Behavior

  • Session should handle large Project Context injection gracefully
  • Circuit breaker should not cause data loss in session store backups
  • Context size estimation should be communicated before tool execution, not after

Environment

  • macOS (Darwin)
  • OpenClaw latest (gateway logs show Apr 23 2026)
  • Model: MiniMax (via API)

Suggested Fixes

  1. Project Context size limits: Set a max cap on how much Project Context can be injected at session start (e.g., 20KB summary instead of full MEMORY.md)
  2. Circuit breaker transparency: Show which session/operation triggered the circuit breaker before it causes session restart
  3. Backup retention policy: Keep at least one pre-crash backup even under circuit breaker conditions
  4. Context estimation pre-check: Warn user/agent when estimated context is approaching overflow threshold before tool execution fails

Workaround

None ideal — users with large MEMORY.md / daily logs have no way to prevent this crash loop.


Reported via OpenClaw agent diagnostic (session diagnostics only, no user content)

extent analysis

TL;DR

Implementing a Project Context size limit, such as summarizing large files like MEMORY.md to 20KB, can help prevent session crashes due to context overflow.

Guidance

  • Verify the issue: Confirm that the session crash is indeed caused by the large Project Context file by checking the error log for the "Context overflow" message and analyzing the session store rotation and cleanup patterns.
  • Test size limits: Experiment with different size limits for Project Context injection to find a balance between data retention and preventing context overflow.
  • Monitor circuit breaker behavior: Observe how the circuit breaker interacts with session store backups to understand how data loss can be mitigated, potentially by adjusting the backup retention policy.
  • Explore pre-check mechanisms: Investigate implementing a warning system when the estimated context size approaches the overflow threshold to prevent tool execution failures.

Example

No specific code snippet is provided due to the lack of explicit code references in the issue, but adjusting the Project Context size limit could involve modifying configuration settings or implementing a summarization function for large files.

Notes

The effectiveness of these suggestions may depend on the specific requirements of the project and the constraints of the OpenClaw system, particularly its handling of large Project Context files and circuit breaker mechanisms.

Recommendation

Apply a workaround by implementing a Project Context size limit, as directly addressing the root cause may require significant changes to the system's architecture or the OpenClaw agent's behavior. This approach can help mitigate the issue until a more comprehensive solution is available.

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