diff --git a/docs/concepts/system-prompt.md b/docs/concepts/system-prompt.md index acb2bf8b5f9..21edbff830d 100644 --- a/docs/concepts/system-prompt.md +++ b/docs/concepts/system-prompt.md @@ -59,11 +59,24 @@ Bootstrap files are trimmed and appended under **Project Context** so the model - `USER.md` - `HEARTBEAT.md` - `BOOTSTRAP.md` (only on brand-new workspaces) +- `MEMORY.md` and/or `memory.md` (when present in the workspace; either or both may be injected) + +All of these files are **injected into the context window** on every turn, which +means they consume tokens. Keep them concise — especially `MEMORY.md`, which can +grow over time and lead to unexpectedly high context usage and more frequent +compaction. + +> **Note:** `memory/*.md` daily files are **not** injected automatically. They +> are accessed on demand via the `memory_search` and `memory_get` tools, so they +> do not count against the context window unless the model explicitly reads them. Large files are truncated with a marker. The max per-file size is controlled by `agents.defaults.bootstrapMaxChars` (default: 20000). Missing files inject a short missing-file marker. +Sub-agent sessions only inject `AGENTS.md` and `TOOLS.md` (other bootstrap files +are filtered out to keep the sub-agent context small). + Internal hooks can intercept this step via `agent:bootstrap` to mutate or replace the injected bootstrap files (for example swapping `SOUL.md` for an alternate persona). diff --git a/docs/reference/token-use.md b/docs/reference/token-use.md index 16b0fe9618c..05562891e01 100644 --- a/docs/reference/token-use.md +++ b/docs/reference/token-use.md @@ -18,7 +18,7 @@ OpenClaw assembles its own system prompt on every run. It includes: - Tool list + short descriptions - Skills list (only metadata; instructions are loaded on demand with `read`) - Self-update instructions -- Workspace + bootstrap files (`AGENTS.md`, `SOUL.md`, `TOOLS.md`, `IDENTITY.md`, `USER.md`, `HEARTBEAT.md`, `BOOTSTRAP.md` when new). Large files are truncated by `agents.defaults.bootstrapMaxChars` (default: 20000). +- Workspace + bootstrap files (`AGENTS.md`, `SOUL.md`, `TOOLS.md`, `IDENTITY.md`, `USER.md`, `HEARTBEAT.md`, `BOOTSTRAP.md` when new, plus `MEMORY.md` and/or `memory.md` when present). Large files are truncated by `agents.defaults.bootstrapMaxChars` (default: 20000). `memory/*.md` files are on-demand via memory tools and are not auto-injected. - Time (UTC + user timezone) - Reply tags + heartbeat behavior - Runtime metadata (host/OS/model/thinking)