MEMORY.md is fully injected into system prompt despite memory_search/memory_get being available
Summary
MEMORY.md is unconditionally injected in full into the system prompt as part of Project Context → Workspace Files. At the same time, the system prompt also instructs the model to use memory_search and memory_get tools for memory recall. This creates a paradox: if the model is expected to search memory on demand, why is the entire memory file pre-loaded into the context on every request?
For users who accumulate substantial long-term memory (rules, milestones, project states, lessons learned), MEMORY.md can easily grow to 9,000+ characters (~2,300–3,800 tokens), making it one of the largest contributors to system prompt cost.
Observed behavior
In a captured request payload from a clean conversation:
MEMORY.md full content (~9k chars) is injected under # Project Context in the system prompt
- The system prompt also contains
## Memory Recall rules instructing the model to run memory_search → memory_get before answering memory-related questions
memory_search and memory_get are both available in body.tools[]
This means the model receives the same information twice: once passively via system prompt injection, and once actively via the search/retrieval tools.
Expected behavior
Ideally, users should have the option to control whether MEMORY.md is fully injected or only accessible via memory_search/memory_get. A possible approach:
Option A: Configuration flag
Add a workspace-level or agent-level config option, e.g.:
workspace_files:
MEMORY.md:
inject: false # do not inject into system prompt; rely on memory_search/memory_get
When inject: false, the file is still indexed by memory_search but not included in the system prompt.
Option B: Encourage content tiering (documentation)
As an interim solution, document the best practice of keeping MEMORY.md lean (only critical, high-frequency rules) and moving detailed/historical content to memory/*.md daily log files, which are not auto-injected but are searchable via memory_search.
Impact
| Scenario |
MEMORY.md size |
Tokens saved per request |
| Light user |
~2k chars |
~500–800 |
| Power user |
~9k+ chars |
~2,300–3,800 |
For power users on pay-per-token providers, this adds up quickly across hundreds of daily interactions.
Environment
- OpenClaw: latest (self-hosted)
- Debug method: custom model provider proxy (modelbox) to capture full request payloads
MEMORY.md is fully injected into system prompt despite
memory_search/memory_getbeing availableSummary
MEMORY.mdis unconditionally injected in full into the system prompt as part of Project Context → Workspace Files. At the same time, the system prompt also instructs the model to usememory_searchandmemory_gettools for memory recall. This creates a paradox: if the model is expected to search memory on demand, why is the entire memory file pre-loaded into the context on every request?For users who accumulate substantial long-term memory (rules, milestones, project states, lessons learned),
MEMORY.mdcan easily grow to 9,000+ characters (~2,300–3,800 tokens), making it one of the largest contributors to system prompt cost.Observed behavior
In a captured request payload from a clean conversation:
MEMORY.mdfull content (~9k chars) is injected under# Project Contextin the system prompt## Memory Recallrules instructing the model to runmemory_search→memory_getbefore answering memory-related questionsmemory_searchandmemory_getare both available inbody.tools[]This means the model receives the same information twice: once passively via system prompt injection, and once actively via the search/retrieval tools.
Expected behavior
Ideally, users should have the option to control whether
MEMORY.mdis fully injected or only accessible viamemory_search/memory_get. A possible approach:Option A: Configuration flag
Add a workspace-level or agent-level config option, e.g.:
When
inject: false, the file is still indexed bymemory_searchbut not included in the system prompt.Option B: Encourage content tiering (documentation)
As an interim solution, document the best practice of keeping
MEMORY.mdlean (only critical, high-frequency rules) and moving detailed/historical content tomemory/*.mddaily log files, which are not auto-injected but are searchable viamemory_search.Impact
For power users on pay-per-token providers, this adds up quickly across hundreds of daily interactions.
Environment