fix: update sessionEntry.contextTokens on model switch#35541
fix: update sessionEntry.contextTokens on model switch#35541ethanperezz wants to merge 1 commit intoopenclaw:mainfrom
Conversation
When switching models via inline directive, applyModelOverrideToSessionEntry updated the model/provider override but left contextTokens unchanged. This caused contextTokens to get stuck at a lower value after switching to a model with a smaller context window and back. Now persistInlineDirectives explicitly updates sessionEntry.contextTokens to match the new model's context window, keeping session state consistent. Fixes openclaw#35372 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Greptile SummaryThis PR fixes a stale- The fix adds a targeted block immediately after the provider/model fields are updated to recompute The change is small, well-contained, and correct for the stated issue. Confidence Score: 5/5
Last reviewed commit: 3af6e63 |
Summary
/model),applyModelOverrideToSessionEntryupdated the model/provider override but leftsessionEntry.contextTokensunchangedcontextTokensto get stuck at a lower value after switching to a model with a smaller context window and back (e.g., 198k → 160k → stays 160k)persistInlineDirectivesexplicitly updatessessionEntry.contextTokensto match the new model's context window before persisting the session storeFixes #35372
Test plan
/model/statusshows the correct context window for Model B/statusshows Model A's context window (198k), not Model B's (160k)contextTokensis updated correctly🤖 Generated with Claude Code