openclaw - 💡(How to fix) Fix Bug: MEMORY.md is silently truncated during bootstrap [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#53731Fetched 2026-04-08 01:24:15
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants
RAW_BUFFERClick to expand / collapse

The agent bootstrap file MEMORY.md gets silently truncated in the injected context when it exceeds a certain character limit (e.g., 20,000).

This happens on every session start, which means the agent is consistently working with an incomplete memory without any warning to the user.

Propuestas de solución:

  1. Hacer el límite configurable: Añadir una opción de configuración como agents.defaults.bootstrapFileSizeLimit para que los usuarios puedan establecer su propio umbral.
  2. Avisar al usuario: Mostrar una advertencia visible en el dashboard o en el chat cuando ocurra el truncamiento, ya que actualmente solo aparece en los logs.
  3. Implementar truncamiento inteligente: Si el truncamiento es inevitable, eliminar las entradas más antiguas (del principio del archivo) en lugar de las más recientes (del final), ya que MEMORY.md suele ser cronológico.

extent analysis

Fix Plan

To address the issue of the agent bootstrap file MEMORY.md getting silently truncated, we will implement the following solutions:

  • Make the limit configurable
  • Warn the user when truncation occurs
  • Implement intelligent truncation

Step-by-Step Solution

1. Make the limit configurable

Add a configuration option agents.defaults.bootstrapFileSizeLimit to allow users to set their own threshold.

# config.py
class Config:
    # ...
    AGENTS_DEFAULTS_BOOTSTRAP_FILE_SIZE_LIMIT = 20000  # default limit

2. Warn the user when truncation occurs

Display a warning in the dashboard or chat when truncation happens.

# agent.py
def load_bootstrap_file(file_path):
    # ...
    if file_size > config.AGENTS_DEFAULTS_BOOTSTRAP_FILE_SIZE_LIMIT:
        print("Warning: Bootstrap file exceeded size limit. Truncation occurred.")
        # display warning in dashboard or chat

3. Implement intelligent truncation

Remove older entries from the beginning of the file instead of newer entries from the end.

# agent.py
def truncate_bootstrap_file(file_path):
    # ...
    with open(file_path, 'r') as file:
        lines = file.readlines()
    # remove older entries from the beginning
    lines = lines[-config.AGENTS_DEFAULTS_BOOTSTRAP_FILE_SIZE_LIMIT:]
    with open(file_path, 'w') as file:
        file.writelines(lines)

Verification

To verify that the fix worked:

  • Set the agents.defaults.bootstrapFileSizeLimit configuration option to a low value (e.g., 1000)
  • Restart the agent and check that the warning is displayed in the dashboard or chat
  • Verify that the MEMORY.md file is truncated correctly, with older entries removed from the beginning

Extra Tips

  • Consider adding a default value for the agents.defaults.bootstrapFileSizeLimit configuration option
  • Make sure to handle edge cases, such as an empty MEMORY.md file or a file with a size limit of 0.

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 Bug: MEMORY.md is silently truncated during bootstrap [1 participants]