feat: add per-agent compaction overrides (AI-assisted)#83637
feat: add per-agent compaction overrides (AI-assisted)#83637kklouzal wants to merge 102 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed May 30, 2026, 9:01 PM ET / 01:01 UTC. Summary Reproducibility: yes. source inspection gives a high-confidence reproduction path: current main has a strict AgentEntrySchema without per-agent compaction/contextPruning and default-only compaction/contextPruning runtime reads. The PR head fixes part of that path for compaction but still leaves per-agent contextPruning rejected or ignored. Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land a narrowed, clean head that implements both per-agent compaction and per-agent contextPruning end to end, removes release/dependency/changelog drift unless explicitly approved, and includes exact-head real behavior proof for config validation plus direct/gateway compaction resolution. Do we have a high-confidence way to reproduce the issue? Yes, source inspection gives a high-confidence reproduction path: current main has a strict AgentEntrySchema without per-agent compaction/contextPruning and default-only compaction/contextPruning runtime reads. The PR head fixes part of that path for compaction but still leaves per-agent contextPruning rejected or ignored. Is this the best way to solve the issue? No, not as submitted: resolving compaction through the active agent is the right direction, but the PR still misses the matching contextPruning contract and carries dependency/release drift. The narrower solution is to complete the shared per-agent config resolver for both blocks and keep unrelated package/release changes out of this PR. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against e9d01320d7f3. Label changesLabel justifications:
Evidence reviewedSecurity concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
24b385e to
dcd31b8
Compare
Dependency GuardThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
Dependency graph changes are blockedOpenClaw does not accept dependency graph changes through PRs unless security explicitly authorizes the current head SHA. Dependency updates are generated internally by maintainers so external PRs cannot change the resolved graph. Detected dependency graph changes:
Auto-scrub was not attempted because this PR changes package manifest dependency graph fields:
Dependency graph changes must be reviewed by security or handled by maintainers internally. Please remove lockfile changes manually if they are not needed. To remove lockfile changes, restore them from the target branch: git fetch origin
git checkout 'origin/main' -- 'extensions/feishu/npm-shrinkwrap.json' 'npm-shrinkwrap.json' 'pnpm-lock.yaml'
git commit -m 'chore: remove dependency lockfile change'
git pushIf this PR intentionally needs a dependency graph change, ask a member of The action will approve the current head SHA ( |
Closing this stale release-base PR. The branch is being kept in the fork for local release-line testing, and any upstream work will be reopened later as a fresh, clean PR.New PR: #88506 |
Summary
Adds per-agent
compactionandcontextPruningoverrides so each configured agent can resolve maintenance/runtime behavior from its active agent scope instead of always inheriting every value fromagents.defaults.This is for multi-agent installations where main, channel/proxy, local/self-hosted, and Codex/app-server agents need different compaction, pruning, timeout, thinking-level, and transcript-maintenance behavior.
Linked Issues And Related Work
Closes #52732
Related: #52751, #69988, #19501, #15826, #43834, #6571, #6572, #30452, #57901, #58077, #59863, #60512, #80784, #82008
Problem / Root Cause
Before this change, per-agent compaction settings were either rejected by schema or only partially honored. Several runtime paths still read
agents.defaults.compaction/agents.defaults.contextPruningeven when the activeagents.list[]entry had its own settings.That weakened these setups:
agentIdpreserved across queued/direct compaction and maintenance pathscompaction.thinkingLevel, not the active run's normal thinking levelWhat Changed
agents.list[].compactionand per-agentcontextPruning.compactionandcontextPruningblocks overagents.defaults, so partial overrides inherit unspecified fields.sessionAgentIdthrough queued/direct compaction, CLI compaction, context-engine maintenance, Codex app-server lifecycle, embedded cache-TTL finalization, memory flush, transcript rotation, and follow-up/notice paths.compaction.modelbehavior separate from Codex/app-server native runtime selection.Reviewer Notes
The key invariant is:
That is why this PR explicitly passes
agentIdinto compaction and maintenance params instead of relying only on parsingsessionKey.Real behavior proof
f723ad186d7879d12c61562dd4c2dab3745b5ed3, covering per-agent compaction override resolution for model/provider, thinking level, timeout, reserve-token floor, small-context reserve-floor capping, clean config validation, focused compaction regression coverage, and actual model/gateway requests after the patch./home/kklouzal/openclaw-pr-83637, detached checkoutf723ad186d7879d12c61562dd4c2dab3745b5ed3, Nodev24.15.0, pnpm11.2.2, modelgithub-copilot/gpt-5-mini, clean proof config at/home/kklouzal/openclaw-pr-83637/.artifacts/proof-refresh-f723ad18-20260527T050453Z/model-home/openclaw.json, redacted artifacts at/home/kklouzal/openclaw-pr-83637/.artifacts/proof-refresh-f723ad18-20260527T050453Z/redacted.f723ad186d7879d12c61562dd4c2dab3745b5ed3, ranpnpm install --frozen-lockfile,pnpm build:strict-smoke, focused compaction Vitest coverage,tsgocore and core-test typechecks,git diff --check, a source-import compaction config proof, cleanopenclaw config validate,openclaw models status --probe --json,openclaw infer model run --local --model github-copilot/gpt-5-mini,OPENCLAW_LIVE_MODELS=github-copilot/gpt-5-mini node scripts/test-live.mjs src/agents/models.profiles.live.test.ts, andOPENCLAW_LIVE_GATEWAY_MODELS=github-copilot/gpt-5-mini node scripts/test-live.mjs src/gateway/gateway-models.profiles.live.test.ts.22files /779tests;build:strict-smoke,tsgocore,tsgocore-test, andgit diff --checkpassed; the compaction config proof returnedstatus: pass; clean config validation passed; direct model output returnedOPENCLAW_PR83637_F723AD18_OK; live direct model suite passed17tests; live gateway suite passed68tests.Redacted command summary and compaction proof
{ "pr": 83637, "head": "f723ad186d7879d12c61562dd4c2dab3745b5ed3", "host": "Nano-01", "artifact": "/home/kklouzal/openclaw-pr-83637/.artifacts/proof-refresh-f723ad18-20260527T050453Z", "commands": { "01-install": "0", "02-build-strict-smoke": "0", "03-config-validate": "1", "04-focused-compaction-tests": "0", "05-tsgo-core": "0", "06-tsgo-core-test": "0", "07-diff-check": "0", "08-compaction-config-proof": "0", "09-clean-config-validate": "0", "10-models-status": "0", "11-model-run": "0", "12-live-models": "0", "13-live-gateway-models": "0" }, "markers": { "model": true, "liveModels": true, "liveGateway": true, "compactionConfig": true } }{ "status": "pass", "head": "f723ad186d7879d12c61562dd4c2dab3745b5ed3", "default": { "timeoutMs": 90000, "think": "minimal", "target": { "provider": "github-copilot", "model": "gpt-5-mini" }, "floor": 20000, "settings": { "applied": { "didOverride": true, "compaction": { "reserveTokens": 20000, "keepRecentTokens": 1024 } }, "reserve": 20000, "keep": 1024 } }, "flat": { "timeoutMs": 61000, "think": "off", "target": { "provider": "openai", "model": "gpt-5.4-mini" }, "floor": 0, "settings": { "applied": { "didOverride": true, "compaction": { "reserveTokens": 2048, "keepRecentTokens": 512 } }, "reserve": 2048, "keep": 512 } }, "nested": { "timeoutMs": 122000, "think": "high", "target": { "provider": "github-copilot", "model": "gpt-5.4-mini", "authProfileId": "copilot-auth" }, "floor": 24000, "settings": { "applied": { "didOverride": true, "compaction": { "reserveTokens": 24000, "keepRecentTokens": 2048 } }, "reserve": 24000, "keep": 2048 } }, "smallWindow": { "applied": { "didOverride": true, "compaction": { "reserveTokens": 8384, "keepRecentTokens": 512 } }, "reserve": 8384, "keep": 512 }, "runtime": { "provider": "openai", "model": "gpt-5.4-mini", "thinkLevel": "off" } }timeoutMs=90000,think=minimal, andgithub-copilot/gpt-5-mini;flat-agentoverrode totimeoutMs=61000,think=off, provider/modelopenai/gpt-5.4-mini, and dropped the mismatched auth profile;nested-agentoverrode totimeoutMs=122000,think=high,github-copilot/gpt-5.4-mini, and retained the matching auth profile; small-context capping reduced reserve tokens to8384for a 16K context budget. Real direct and gateway model requests completed successfully after the patch.Validation
Acceptance commands requested by ClawSweeper:
Result:
Schema baseline:
Config docs baseline:
Note: this docs-baseline check initially caught stale committed hash drift. I regenerated
docs/.generated/config-baseline.sha256, committed it as04170e48eb01fc29f7f3acb1a830c5742b41c3ea, and reran the check successfully.Additional gate:
Final Merge/Polish Validation
After conflict cleanup, final branch polish, and the latest main merge repair, the PR was pushed at
f239d594d22b56837bb371770898c30759e81515. The final name-only diff is scoped to compaction, context-pruning, Codex app-server compaction, memory-flush maintenance, docs, schema baselines, and regression tests; the unrelated memory-slot architecture leak has been removed from this PR surface.Final local gates on the pushed head:
Current Branch State
mainf239d594d22b56837bb371770898c30759e81515