-
-
Notifications
You must be signed in to change notification settings - Fork 69.4k
[Bug]: Session contextTokens gets stuck at lower model limit after model switch (e.g. 198k -> 160k -> stays 160k) #35372
Copy link
Copy link
Labels
bugSomething isn't workingSomething isn't workingbug:behaviorIncorrect behavior without a crashIncorrect behavior without a crash
Description
Bug type
Behavior bug (incorrect output/state without crash)
Summary
When switching models in an existing session, contextTokens can become "stuck" at a lower value.
Example:
- Model A context window: ~198k
- Switch to Model B context window: ~160k
- Switch back to Model A
- Session still reports/uses ~160k context window (in session file and runtime behavior)
This causes premature compaction and incorrect context accounting.
Steps to reproduce
- Configure two models with different context windows (for example 198k and 160k).
- Start a session (OpenClaw TUI / gateway-client).
- Use Model A (198k).
- Switch to Model B (160k).
- Switch back to Model A (198k).
- Check
/statusand/or session store file (contextTokens).
Expected behavior
- Context window should update based on the currently selected provider/model each time.
- After switching back to Model A, context should return to ~198k
Actual behavior
contextTokensremains at the lower value (~160k) and appears effectively hardcoded in session state.- Switching back to higher-context model does not restore the larger context window in that session.
OpenClaw version
2026.3.2
Operating system
Ubuntu 24.04.4
Install method
npm global
Logs, screenshots, and evidence
n/aImpact and severity
- Early compaction / pruning
- Incorrect status reporting
- Reduced usable context in long-running sessions
Additional information
This looks related to previous context-window cache/provider-resolution issues:
- [Bug]: context window size not updated per provider/model #27394
- fix(context): resolve context windows per provider/model across status and run accounting #27439
- fix: use provider-qualified key in MODEL_CACHE for context window lookup #15632
- fix(status): use full provider/model key for context window lookup #27500
- fix: refactor context window cache to be provider-scoped #34511
- Fix contextWindow collision across providers #9382
Could be a regression or another path where session state keeps stale contextTokens after model switch
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingbug:behaviorIncorrect behavior without a crashIncorrect behavior without a crash
Type
Fields
Give feedbackNo fields configured for issues without a type.