openclaw - 💡(How to fix) Fix modelByChannel override does not update session's persisted contextTokens — /status shows stale value [1 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#63425Fetched 2026-04-09 07:53:54
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

When modelByChannel overrides the runtime model for a session (e.g. from claude-opus-4-6 to minimax), the session's persisted contextTokens value is not updated. /status continues to show the old model's context window (e.g. 1M instead of minimax's actual 204k).

Root Cause

Root Cause (source-code traced)

Fix Action

Workaround

Send /new in the affected chat to create a fresh session — the new session picks up the correct context window from the active model.

RAW_BUFFERClick to expand / collapse

Description

When modelByChannel overrides the runtime model for a session (e.g. from claude-opus-4-6 to minimax), the session's persisted contextTokens value is not updated. /status continues to show the old model's context window (e.g. 1M instead of minimax's actual 204k).

Root Cause (source-code traced)

In status-yaHSTeGo.js:

  1. resolveContextTokensForModel() checks contextTokensOverride (session persisted) first
  2. The session entry's contextTokens: 1048576 was persisted from the previous model (claude-opus-4-6)
  3. modelByChannel switches the runtime model to minimax, but the session's persisted contextTokens is not updated
  4. /status uses persistedContextTokens with priority, so it displays the stale 1M value

Expected Behavior

When modelByChannel overrides the model, /status should reflect the actual context window of the active model (204k for minimax), not the persisted value from a previous model.

Suggested Improvement

When modelByChannel override is active for a session, either:

  1. Clear/update the session's persisted contextTokens to match the new model, or
  2. Have /status prefer the active model's context window over persisted values when a modelByChannel override is in effect

Workaround

Send /new in the affected chat to create a fresh session — the new session picks up the correct context window from the active model.

Environment

  • OpenClaw 2026.4.5
  • modelByChannel switching from anthropic to minimax provider

extent analysis

TL;DR

Update the session's persisted contextTokens to match the new model when modelByChannel overrides the runtime model.

Guidance

  • Identify sessions where modelByChannel has overridden the runtime model and update their persisted contextTokens to the new model's context window.
  • Modify the /status endpoint to prefer the active model's context window over persisted values when a modelByChannel override is in effect.
  • Consider implementing a mechanism to automatically update persisted contextTokens when the model is switched via modelByChannel.
  • Verify the fix by checking the /status endpoint for affected sessions and ensuring it reflects the correct context window for the active model.

Example

// Example of updating persisted contextTokens in status-yaHSTeGo.js
if (modelByChannelOverrideActive) {
  const newModelContextTokens = getActiveModelContextTokens();
  session.contextTokens = newModelContextTokens;
}

Notes

This solution assumes that the modelByChannel override is properly detected and handled in the code. Additionally, the getActiveModelContextTokens() function is not defined in the issue, so its implementation is left to the developer.

Recommendation

Apply workaround: Send /new in the affected chat to create a fresh session, which will pick up the correct context window from the active model, until a permanent fix can be implemented.

FAIL-SAFE: If the issue lacks enough information, the above guidance points provide a safe starting point for investigation and potential fix.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING