You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/concepts/compaction.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,6 +91,11 @@ This works with local models too, for example a second Ollama model dedicated to
91
91
```
92
92
93
93
When unset, compaction starts with the active session model. If summarization fails with a model-fallback-eligible provider error, OpenClaw retries that compaction attempt through the session's existing model fallback chain. The fallback choice is temporary and is not written back to session state. An explicit `agents.defaults.compaction.model` override remains exact and does not inherit the session fallback chain.
94
+
Per-agent `agents.list[].compaction.model` overrides are also supported. Omit `agents.list[].compaction` to inherit `agents.defaults.compaction`; set only the per-agent fields that should differ. Per-agent `agents.list[].compaction` deep-merges over `agents.defaults.compaction`, so unspecified fields continue to inherit the defaults.
95
+
96
+
### Thinking level
97
+
98
+
By default, compaction uses the active session thinking level. Set `agents.defaults.compaction.thinkingLevel` to use a fixed reasoning budget for compaction summarization, such as `"off"` for cheaper summaries or `"high"` for stronger retention audits. Per-agent `agents.list[].compaction.thinkingLevel` overrides are also supported and deep-merge over the default compaction block.
94
99
95
100
### Identifier preservation
96
101
@@ -150,6 +155,7 @@ Before compaction, OpenClaw can run a **silent memory flush** turn to store dura
150
155
```
151
156
152
157
The memory-flush model override is exact and does not inherit the active session fallback chain. See [Memory](/concepts/memory) for details and config.
158
+
Per-agent `agents.list[].compaction.memoryFlush.model` overrides are supported through the same merge semantics: omit `agents.list[].compaction` to inherit the default block, or set only the nested `memoryFlush` fields that should differ for that agent.
truncateAfterCompaction:true, // rotate to a smaller successor JSONL after compaction
647
648
maxActiveTranscriptBytes:"20mb", // optional preflight local compaction trigger
648
649
notifyUser:true, // send brief notices when compaction starts and completes (default: false)
@@ -669,10 +670,13 @@ Periodic heartbeat runs.
669
670
-`midTurnPrecheck`: optional tool-loop pressure check. When `enabled: true`, OpenClaw checks context pressure after tool results are appended and before the next model call. If the context no longer fits, it aborts the current attempt before submitting the prompt and reuses the existing precheck recovery path to truncate tool results or compact and retry. Works with both `default` and `safeguard` compaction modes. Default: disabled.
670
671
-`postCompactionSections`: optional AGENTS.md H2/H3 section names to re-inject after compaction. Reinjection is disabled when unset or set to `[]`. Explicitly setting `["Session Startup", "Red Lines"]` enables that pair and preserves the legacy `Every Session`/`Safety` fallback. Enable this only when the extra context is worth the risk of duplicating project guidance already captured in the compaction summary.
671
672
-`model`: optional `provider/model-id` override for compaction summarization only. Use this when the main session should keep one model but compaction summaries should run on another; when unset, compaction uses the session's primary model.
673
+
-`thinkingLevel`: optional compaction-only thinking level (`off | minimal | low | medium | high | xhigh | adaptive | max`). When unset, compaction uses the active session thinking level; set `off` to disable reasoning for compaction.
672
674
-`maxActiveTranscriptBytes`: optional byte threshold (`number` or strings like `"20mb"`) that triggers normal local compaction before a run when the active JSONL grows past the threshold. Requires `truncateAfterCompaction` so successful compaction can rotate to a smaller successor transcript. Disabled when unset or `0`.
673
675
-`notifyUser`: when `true`, sends brief notices to the user when compaction starts and when it completes (for example, "Compacting context..." and "Compaction complete"). Disabled by default to keep compaction silent.
674
676
-`memoryFlush`: silent agentic turn before auto-compaction to store durable memories. Set `model` to an exact provider/model such as `ollama/qwen3:8b` when this housekeeping turn should stay on a local model; the override does not inherit the active session fallback chain. Skipped when workspace is read-only.
675
677
678
+
Per-agent `agents.list[].compaction` blocks are supported. Omit the block to inherit `agents.defaults.compaction`. Set only the fields that should differ for an agent; per-agent compaction blocks deep-merge over the default block.
679
+
676
680
### `agents.defaults.runRetries`
677
681
678
682
Outer run loop retry iteration boundaries for the embedded agent runtime to prevent infinite execution loops during failure recovery. Note that this setting currently only applies to the embedded agent runtime, not ACP or CLI runtimes.
@@ -1099,6 +1103,7 @@ for provider examples and precedence.
1099
1103
-`thinkingDefault`: optional per-agent default thinking level (`off | minimal | low | medium | high | xhigh | adaptive | max`). Overrides `agents.defaults.thinkingDefault` for this agent when no per-message or session override is set. The selected provider/model profile controls which values are valid; for Google Gemini, `adaptive` keeps provider-owned dynamic thinking (`thinkingLevel` omitted on Gemini 3/3.1, `thinkingBudget: -1` on Gemini 2.5).
1100
1104
-`reasoningDefault`: optional per-agent default reasoning visibility (`on | off | stream`). Overrides `agents.defaults.reasoningDefault` for this agent when no per-message or session reasoning override is set.
1101
1105
-`fastModeDefault`: optional per-agent default for fast mode (`true | false`). Applies when no per-message or session fast-mode override is set.
1106
+
-`compaction`: optional per-agent compaction policy. If omitted, the agent inherits `agents.defaults.compaction`. If set, the block deep-merges over the default for that agent, including nested `qualityGuard`, `midTurnPrecheck`, and `memoryFlush` fields.
1102
1107
-`models`: optional per-agent model catalog/runtime overrides keyed by full `provider/model` ids. Use `models["provider/model"].agentRuntime` for per-agent runtime exceptions.
1103
1108
-`runtime`: optional per-agent runtime descriptor. Use `type: "acp"` with `runtime.acp` defaults (`agent`, `backend`, `mode`, `cwd`) when the agent should default to ACP harness sessions.
1104
1109
-`identity.avatar`: workspace-relative path, `http(s)` URL, or `data:` URI.
0 commit comments