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
{{ message }}
Repository navigation
[Feature]: Support per-agent compaction settings (mode, reserveTokensFloor, memoryFlush) in agents.list[] #13736
Currently, compaction settings in OpenClaw (such as compaction mode, reserveTokensFloor, and memoryFlush configuration) are only configurable in agents.defaults.compaction. There is no way to override compaction settings for individual agents listed in agents.list[], unlike other features such as heartbeat, sandbox, and tools which support per-agent overrides.
This limits flexibility. Some use cases might require different context window management strategies for different agents (e.g. long-running research agents vs. quick-turnaround chat agents).
Proposed solution
Allow compaction settings (mode, reserveTokensFloor, memoryFlush, etc) to be optionally specified per-agent in agents.list[], following the pattern used for heartbeat and tools overrides. When a compaction config is present for an agent, it would override the defaults for that agent only.
Additional context
Example of per-agent configuration: agents.list[].heartbeat in the OpenClaw configuration.
It adds compaction (mode, reserveTokensFloor, maxHistoryShare, memoryFlush) and contextPruning to agents.list[] entries, with deep merge against global defaults. Per-agent memoryFlush.prompt overrides are included so different agents can store different types of context during flush.
Integration tested on a live gateway with custom reserveTokensFloor and mode: "off" — both working as expected.
If this would be useful for your setup, a 👍 on the PR helps signal demand to maintainers. Would also love any feedback if you get a chance to look at it.
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.
This is a valid core feature request, but the remaining work is now tracked by the canonical open implementation PR #69988. Current main still does not implement per-agent compaction overrides: the per-agent type and strict schema lack agents.list[].compaction, resolver/runtime paths still read defaults-only compaction settings, and docs expose only agents.defaults.compaction. Earlier implementation attempts #14598 and #19329, including the live-gateway testing noted by curtismercier, are closed unmerged; #69988 is the active focused path.
Best possible solution:
Close this issue as superseded by #69988 and keep review focused on that PR. The best implementation remains a core config/runtime change: add optional agents.list[].compaction to the public type and strict schema, reuse the defaults compaction schema, deep-merge per-agent values over agents.defaults.compaction including nested memoryFlush, thread the effective config through Pi settings, safeguard runtime, compaction model/provider/timeout paths, memory-flush/preflight behavior, generated config help/docs, and focused schema/resolver/runtime tests.
What I checked:
Current main checked: Reviewed current main at 43da089; git status --short returned clean before read-only inspection. (43da08979035)
Canonical open implementation PR: GitHub API shows feat(config): support per-agent compaction overrides #69988 is open, unmerged, titled feat(config): support per-agent compaction overrides, and its body describes adding optional agents.list[].compaction, merging it over defaults, and threading effective per-agent config through embedded runtime compaction paths. (eadf56e7c978)
Current issue state and labels: GitHub API shows this issue is still open, author association NONE, and only has the enhancement label, so no maintainer/protected-label rule blocks duplicate cleanup.
Per-agent type lacks compaction:AgentConfig includes per-agent model, skills, memorySearch, contextLimits, heartbeat, sandbox, params, tools, and runtime fields, but no compaction property. (src/config/types.agents.ts:76, 43da08979035)
Compaction type is defaults-owned:AgentDefaultsConfig exposes compaction?: AgentCompactionConfig, and the compaction type contains the requested knobs including mode, reserveTokensFloor, maxHistoryShare, customInstructions, and nested memoryFlush. (src/config/types.agent-defaults.ts:280, 43da08979035)
Strict agent schema rejects per-agent compaction:AgentEntrySchema enumerates allowed agents.list[] fields and ends with .strict() without a compaction property. (src/config/zod-schema.agent-runtime.ts:827, 43da08979035)
Likely related people:
Peter Steinberger [email protected]: Remote history shows Peter authored recent compaction and memory-flush/defaults work, including pre-compaction memory flush, compaction headroom, manual keepRecentTokens behavior, oversized transcript compaction, and memory flush model override across config/docs/runtime paths. (role: recent maintainer and compaction/defaults owner; confidence: high; commits: 7dbb21be8e57, a3747b1ee3ae, 7920f8d4fdeb; files: src/config/types.agent-defaults.ts, src/config/zod-schema.agent-defaults.ts, src/agents/pi-settings.ts)
Tak Hoffman [email protected]: Commit history for src/agents/pi-settings.ts and defaults config shows Tak introduced the exposed Pi compaction tuning values that include the requested reserve/keep-recent tuning surface. (role: introduced Pi compaction tuning surface; confidence: medium; commits: c1ac37a6410a; files: src/agents/pi-settings.ts, src/config/types.agent-defaults.ts, src/config/zod-schema.agent-defaults.ts)
Josh Lehman [email protected]: Remote history shows Josh authored the context-engine integration that routes compaction through pluggable context management and touches the same runtime compaction boundary. (role: adjacent context-management owner; confidence: medium; commits: fee91fefceb4; files: src/agents/pi-settings.ts, src/agents/pi-embedded-runner/extensions.ts, src/agents/pi-embedded-runner/run.ts)
Vincent Koc [email protected]: Remote history shows Vincent recently extracted leaf type surfaces, isolated agent-scope helpers, and worked on embedded extension/runtime seams adjacent to where per-agent compaction would be threaded. (role: recent config/runtime refactor maintainer; confidence: medium; commits: 74e7b8d47b18, a372e4a15240, 91ac48524610; files: src/config/types.agents.ts, src/config/zod-schema.agent-runtime.ts, src/agents/agent-scope-config.ts)
So I’m closing this here and keeping the remaining discussion on the canonical linked item.
Codex review notes: model gpt-5.5, reasoning high; reviewed against 43da08979035.
Activity
curtismercier commentedon Feb 17, 2026
Hey @TeemuSailynoja — I've opened a PR that implements this: #19329
It adds
compaction(mode, reserveTokensFloor, maxHistoryShare, memoryFlush) andcontextPruningtoagents.list[]entries, with deep merge against global defaults. Per-agentmemoryFlush.promptoverrides are included so different agents can store different types of context during flush.Integration tested on a live gateway with custom
reserveTokensFloorandmode: "off"— both working as expected.If this would be useful for your setup, a 👍 on the PR helps signal demand to maintainers. Would also love any feedback if you get a chance to look at it.
TeemuSailynoja commentedon Feb 17, 2026
Very cool, thank you!
steipete commentedon Apr 26, 2026
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.
This is a valid core feature request, but the remaining work is now tracked by the canonical open implementation PR #69988. Current main still does not implement per-agent compaction overrides: the per-agent type and strict schema lack
agents.list[].compaction, resolver/runtime paths still read defaults-only compaction settings, and docs expose onlyagents.defaults.compaction. Earlier implementation attempts #14598 and #19329, including the live-gateway testing noted by curtismercier, are closed unmerged; #69988 is the active focused path.Best possible solution:
Close this issue as superseded by #69988 and keep review focused on that PR. The best implementation remains a core config/runtime change: add optional
agents.list[].compactionto the public type and strict schema, reuse the defaults compaction schema, deep-merge per-agent values overagents.defaults.compactionincluding nestedmemoryFlush, thread the effective config through Pi settings, safeguard runtime, compaction model/provider/timeout paths, memory-flush/preflight behavior, generated config help/docs, and focused schema/resolver/runtime tests.What I checked:
git status --shortreturned clean before read-only inspection. (43da08979035)feat(config): support per-agent compaction overrides, and its body describes adding optionalagents.list[].compaction, merging it over defaults, and threading effective per-agent config through embedded runtime compaction paths. (eadf56e7c978)enhancementlabel, so no maintainer/protected-label rule blocks duplicate cleanup.AgentConfigincludes per-agent model, skills, memorySearch, contextLimits, heartbeat, sandbox, params, tools, and runtime fields, but nocompactionproperty. (src/config/types.agents.ts:76, 43da08979035)AgentDefaultsConfigexposescompaction?: AgentCompactionConfig, and the compaction type contains the requested knobs includingmode,reserveTokensFloor,maxHistoryShare,customInstructions, and nestedmemoryFlush. (src/config/types.agent-defaults.ts:280, 43da08979035)AgentEntrySchemaenumerates allowedagents.list[]fields and ends with.strict()without acompactionproperty. (src/config/zod-schema.agent-runtime.ts:827, 43da08979035)Likely related people:
src/config/types.agent-defaults.ts,src/config/zod-schema.agent-defaults.ts,src/agents/pi-settings.ts)src/agents/pi-settings.tsand defaults config shows Tak introduced the exposed Pi compaction tuning values that include the requested reserve/keep-recent tuning surface. (role: introduced Pi compaction tuning surface; confidence: medium; commits: c1ac37a6410a; files:src/agents/pi-settings.ts,src/config/types.agent-defaults.ts,src/config/zod-schema.agent-defaults.ts)src/agents/pi-settings.ts,src/agents/pi-embedded-runner/extensions.ts,src/agents/pi-embedded-runner/run.ts)src/config/types.agents.ts,src/config/zod-schema.agent-runtime.ts,src/agents/agent-scope-config.ts)So I’m closing this here and keeping the remaining discussion on the canonical linked item.
Codex review notes: model gpt-5.5, reasoning high; reviewed against 43da08979035.