Skip to content

fix: sync model.context_length on --global model switch - #17245

Closed
solink7 wants to merge 1 commit into
NousResearch:mainfrom
solink7:fix/sync-context-length-on-model-switch
Closed

fix: sync model.context_length on --global model switch#17245
solink7 wants to merge 1 commit into
NousResearch:mainfrom
solink7:fix/sync-context-length-on-model-switch

Conversation

@solink7

@solink7 solink7 commented Apr 29, 2026

Copy link
Copy Markdown

Problem

When using /model <name> --global, the resolved context length was displayed correctly in the switch confirmation but not persisted to config.yaml. This caused:

  • model.context_length stayed at the old model value
  • Compression thresholds and token budgets used stale context window
  • Users switching between models (e.g. gpt-5.5 to mimo-v2.5-pro) got incorrect context limits

Root Cause

In _apply_model_switch_result(), the context length was resolved via resolve_display_context_length() for display, but the persist_global block only saved model.default and model.provider — it never saved model.context_length.

Fix

  • Extract ctx variable to outer scope so it is available after the try/except block
  • When persist_global is true and ctx is resolved, save it with save_config_value("model.context_length", ctx)

Testing

  • All existing model switch tests pass (28/28)
  • Full tests/hermes_cli/ suite: 3168 passed, 13 failed (pre-existing, unrelated)

When using /model <name> --global, the resolved context length was
displayed but not persisted to config.yaml. This caused a mismatch:
the new model's context window was shown correctly in the switch
confirmation, but compression thresholds and token budgets continued
using the old model's context_length from config.

Now model.context_length is saved alongside model.default and
model.provider when --global is specified.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard area/config Config system, migrations, profiles labels Apr 29, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #10157 and #10366 (warn on stale context_length), and #15706 / #11437 (context-length alignment). This PR goes further by auto-syncing the value rather than just warning.

@solink7

solink7 commented Apr 29, 2026

Copy link
Copy Markdown
Author

Superseded by #17246 which includes both the config persistence fix and runtime display update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants