Repository navigation
fix(agents): clamp configured input caps to model windows - #144168
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 10, 2026, 12:54 PM ET / 16:54 UTC (Revision 2). ClawSweeper reviewWhat this changesShares configured context-limit calculation so agent startup and compaction clamp input budgets to model ceilings while preserving existing numeric normalization and model selection. Merge readiness⛔ Blocked before merge - 1 item remains The fix remains necessary and has no blocking findings. The added config-loaded startup and saved-state evidence addresses the earlier review request; the related merged work does not fix this remaining guard inconsistency. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw resolves model configuration and metadata into a usable context budget. Agent startup checks that budget against its minimum, and compaction uses it to limit conversation processing. flowchart TD
A[Selected model configuration] --> C[Shared configured limit calculation]
B[Provider ceiling rules] --> C
C --> D[Effective context budget]
D --> E[Startup minimum check]
E --> F[Run agent or show existing error]
D --> G[Compaction budget]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +35, Tests +147. Total +182 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one configured-limit calculation for reporting and runtime budgets, retaining the accepted minimum-window enforcement and existing actionable error. Do we have a high-confidence way to reproduce the issue? Yes: current-main source admits contextTokens=16000 over contextWindow=3000, and the supplied baseline CLI evidence demonstrates that path. This read-only review did not execute tests or target code. Is this the best way to solve the issue? Yes: reusing the existing configured-limit owner fixes the runtime discrepancy while retaining row selection, omitted-cap behavior, provider ceilings, and caller normalization. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 680fc46558fd. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
Related: #144009, #124303
What Problem This Solves
Fixes an issue where a configured input cap larger than a model's native context window could bypass the startup minimum and overstate its compaction budget. A custom model with a 3,000-token native window and a 16,000-token input cap was admitted with a 16,000-token budget.
Why This Change Was Made
Share the existing configured-limit calculation between cache reporting and the runtime guard. Apply the configured or fixed provider ceiling before checking the minimum, while preserving exact model-row selection, omitted-cap behavior and explicit overrides above lower discovered metadata.
The shared owner retains each caller's numeric rules: the guard uses finite whole tokens, while cache reporting keeps its existing positive-number projection. The configuration schema permits positive fractional native windows.
User Impact
Startup and compaction respect configured model ceilings. A native window below the supported minimum produces the existing actionable error even when its input cap is larger.
Evidence
Eleven regression/control cases were executed once on the baseline: four failed and seven passed. The same cases then all passed with the production repair, alongside 20 existing controls for row selection, fixed windows, explicit overrides and caller budgets. Baseline routes were completed separately because the wrapper stopped after each failing route.
An initial static pass found a test-only map-spread lint issue. Replacing it with an equivalent fresh-object Object.assign mapping preserved the cases, assertions and all production bytes; all 29 final checks then passed. Runtime tests were not repeated solely for that syntax change. Independent review found no actionable findings.
Production adds 35 lines for the shared result and existing numeric rules; the row selector becomes private. Tests add 147 lines. The focused tests cover ordinary setup/compaction and metadata helpers. The additional CLI proof below exercises persisted configuration and real agent startup with a synthetic loopback provider.
Config-loaded startup and saved-state continuity
Six runs used the supported
pnpm openclaw agent execentry point. Both pinned source versions built through the normal wrapper and loaded actual config files.ctx=5000ctx=5000Config bytes stayed identical. The reused-state cases began with byte-identical baseline-created state, including SQLite databases. Successful runs returned the fixed mock response; rejected runs emitted the existing actionable floor error before any provider dispatch. All processes closed cleanly.
This verifies source/config startup and saved-state continuity, not npm installation, a released-package upgrade, Gateway service startup, or a live provider. Each process used isolated state and an environment allowlist, with outbound traffic restricted to the task-owned loopback provider.
The intentional behavior change is accepted on this evidence: an oversized input cap no longer masks an unsupported native window. The config format and saved config bytes are unchanged; operators receive the existing guidance to correct the model limit or select a larger model.