Repository navigation
fix(agents): preserve runtime settings overrides [AI-assisted] - #92237
vincentkoc merged 1 commit into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 21, 2026, 1:41 PM ET / 17:41 UTC. Summary PR surface: Source +10, Tests +98. Total +108 across 4 files. Reproducibility: yes. at source level: current main and Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Next step before merge
Security Review detailsBest possible solution: Land the narrow Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main and Is this the best way to solve the issue? Yes. Keeping runtime overrides inside AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against eea777c9fc9c. Label changesLabel justifications:
Evidence reviewedPR surface: Source +10, Tests +98. Total +108 across 4 files. View PR surface stats
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
|
Summary
SettingsManager.applyOverrides()as a runtime override layer instead of merging it only into the current settings snapshotsave()andreload()reserveTokensFlooris applied before runtime auto-compaction/retry guards write settingsWhy
Embedded agent runs can apply a configured compaction reserve floor, then call setters such as
setCompactionEnabled(false)orsetRetryEnabled(false). Those setters callsave(), andsave()previously rebuiltsettingsfrom global/project settings only. That dropped runtime overrides fromapplyOverrides(), so a configured reserve floor such as50000could fall back to the default runtime reserve (16384) inside the same turn.Real behavior proof
reserveTokensFloor=50000must remain the effective reserve aftersetCompactionEnabled(false)persistsenabled=false.openclaw/openclawatorigin/main(575cae59d4) plus this patch, Node via the repo toolchain, no channel credentials or provider API keys used.SettingsManager.inMemory({ compaction: { enabled: true, reserveTokens: 16384 } })from the patched source modules.applyAgentCompactionSettingsFromConfig()withagents.defaults.compaction.reserveTokensFloor=50000andcontextTokenBudget=200000.applyAgentAutoCompactionGuard()withcompactionMode: "safeguard", which writescompaction.enabled=falsethrough the realSettingsManagersetter.settingsManager.reload()and printedsettingsManager.getCompactionSettings().node --import tsx -e 'import { SettingsManager } from "./src/agents/sessions/settings-manager.ts"; import { applyAgentAutoCompactionGuard, applyAgentCompactionSettingsFromConfig } from "./src/agents/agent-settings.ts"; const settingsManager = SettingsManager.inMemory({ compaction: { enabled: true, reserveTokens: 16384 } }); applyAgentCompactionSettingsFromConfig({ settingsManager, cfg: { agents: { defaults: { compaction: { reserveTokensFloor: 50000 } } } }, contextTokenBudget: 200000 }); applyAgentAutoCompactionGuard({ settingsManager, compactionMode: "safeguard" }); await settingsManager.reload(); console.log(JSON.stringify(settingsManager.getCompactionSettings()));'{"enabled":false,"reserveTokens":50000,"keepRecentTokens":20000}enabled=falsefrom the guard write and keepreserveTokens=50000from the runtime override after reload. Before this patch, runtime overrides were only merged into the currentsettingssnapshot, so a later write/reload path could drop the configured reserve back to the backing settings/default.AI-assisted PR; I understand the code path. Maintainer edits are OK on this fork branch.
Tests
node scripts/test-projects.mjs src/agents/agent-settings.test.ts src/agents/agent-project-settings.test.ts src/agents/sessions/settings-manager.test.tspnpm tsgo:corepnpm exec oxlint src/agents/sessions/settings-manager.ts src/agents/sessions/settings-manager.test.ts src/agents/agent-project-settings.test.ts src/agents/agent-settings.test.tsgit diff --checkcodex review --base origin/main(no actionable regressions)Not fully run:
pnpm checkafter the final patch. I ran it once; all preflight guards through shrinkwrap passed, then typecheck caught the missing definite assignment initializer that this commit fixes. A laterpnpm tsgo:corepassed.pnpm lintviascripts/run-oxlint-shards.mjsstalled locally with no worker CPU, so I ran oxlint directly on the touched files instead.