Repository navigation
refactor(config): consolidate context budget to one per-model knob - #124665
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 16, 2026, 12:46 PM ET / 16:46 UTC. ClawSweeper reviewWhat this changesThe branch consolidates context-budget configuration around per-model context windows and migrates retired provider- and agent-level caps. Merge readinessKeep open: the refactor makes a package-exported Plugin SDK field optional without a versioned compatibility path, which can break existing provider plugins that treat it as a number. Priority: P1 Review scores
Verification
How this fits togetherProvider and model configuration feeds context-budget resolution, model catalogs, and status output. External provider plugins can consume the same model-definition type through OpenClaw’s Plugin SDK. flowchart LR
Config[Operator and plugin model config] --> Loader[Config loading and migration]
Loader --> Resolver[Context budget resolution]
Resolver --> Runtime[Agent runtime and status]
Config --> SDK[Published Plugin SDK types]
SDK --> Plugins[External provider plugins]
Decision needed
Why: This changes a package-exported SDK type, so compatibility policy cannot safely be inferred from the internal refactor alone. Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the external model-definition projection required, or introduce a separately versioned optional input contract with documented migration support. Do we have a high-confidence way to reproduce the issue? Yes—an external plugin that assigns Is this the best way to solve the issue? No—the internal simplification should not silently weaken a public Plugin SDK contract; preserve the required projection or version the new contract. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against eb63cb148115. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
85c72a4 to
0a43376
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Merged via squash.
|
…penclaw#124665) * refactor(config): consolidate context budget settings * test(config): type legacy context fixtures * test(config): align context budget fixtures * fix(status): honor runtime context discovery * docs(config): clarify context budget fallbacks * fix(ci): resolve context budget lint failures * test(ci): align context budget shard fixtures * fix(models): preserve catalog context metadata * fix(config): surface context migration diagnostics * test(plugin-sdk): keep live catalog coverage focused
What Problem This Solves
OpenClaw had six configuration paths that could set a model's effective context budget: provider-level
contextTokensandcontextWindow, per-modelcontextTokensandcontextWindow,agents.defaults.contextTokens, andagents.entries.<id>.contextTokens. One number, six knobs. The resolution ladder merging them needed exact-vs-normalized provider matching, asourceCfgside-channel solely to distinguish operator-authoredcontextWindowvalues from the 200k default that normalization used to bake into every model entry, and agent-cap override plumbing threaded through eight production files.Two latent bugs lived in that complexity, fixed here:
agentCfg?.contextTokens ?? 0— literally zero context tokens — whenever no agent-level cap was configured.Why This Change Was Made
Maintainer decision (steipete): consolidate to one knob pair. Every comparable product (Claude Code, Codex CLI, opencode, LiteLLM) exposes exactly one per-model context limit; none has a multi-level ladder.
models.providers.<p>.models[].contextTokens(active-input cap) andmodels.providers.<p>.models[].contextWindow(native window declaration).contextTokens/contextWindow,agents.defaults.contextTokens, per-agent-entrycontextTokens.contextWindowinto model entries, which deletes thesourceCfgauthored-vs-filled hack outright.Old configs keep booting: a raw pre-validation migration (same load-boundary pattern as the persisted-roster migration) bakes provider-level values into explicit model entries and strips retired keys in-memory before strict Zod validation.
openclaw doctor --fixpersists the same migration to disk, reporting every moved/removed key, and the retirement is registered in the doctor deprecation-compat inventory.User Impact
models.providers.<p>.models[].contextTokens). This capability narrowing is an explicit maintainer decision.Evidence
node scripts/run-vitest.mjs.pnpm buildpass;pnpm docs:check-config-examples768 files / 1,174 fences pass;pnpm tsgo:core:testpass.check:assertion-safetynote: theserver.auth.control-ui.pairing.suite.ts: 6 < 11line is a shrink advisory (exit 0) from main's refactor: replace runtime mock seams with dependency injection #124634 refactor; file and baseline untouched here.check-lintred on earlier runs was main-owned breakage from fix: avoid nesting dedicated Linux workers #124636 (scripts/check-changed.mtsboolean-literal-compare), fixed in-flight by fix(config): correct compaction mode help text; repair main lint + qa-lab flake #124656 and picked up here via rebase — not part of this diff.