Skip to content

fix(model): warn on stale context_length after /model --global - #10366

Open
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/model-global-context-warning
Open

fix(model): warn on stale context_length after /model --global#10366
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/model-global-context-warning

Conversation

@LeonSGP43

Copy link
Copy Markdown
Contributor

Summary

  • warn when /model --global leaves an existing model.context_length override out of sync with the newly selected model
  • preserve the explicit override instead of auto-rewriting it, while pointing users to /context <n> when they do want to update it
  • surface the same warning in both the terminal CLI and gateway /model command, with focused regression coverage

Fixes #10157

Testing

  • python3 -m pytest -o addopts="-m 'not integration'" tests/hermes_cli/test_model_switch_context_length_warning.py -q
  • python3 -m pytest -o addopts="-m 'not integration'" tests/cli/test_model_switch_context_warning.py -q
  • python3 -m pytest -o addopts="-m 'not integration'" tests/gateway/test_model_command_custom_providers.py -q
  • python3 -m pytest -o addopts="-m 'not integration'" tests/hermes_cli/test_model_switch_custom_providers.py -q
  • python3 -m pytest -o addopts="-m 'not integration'" tests/gateway/test_model_switch_persistence.py -q

@alt-glitch alt-glitch added type/feature New feature or request comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have labels Apr 26, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for preserving the explicit override rather than silently rewriting it. The stale-override premise still exists on current main: cli.py:7946-7949 persists only the model/provider, and the gateway persists the same fields at gateway/slash_commands.py:1916-1923.

Problems

  • hermes_cli/model_switch.py:133 uses ModelInfo.context_window before provider-aware resolution. Current resolve_display_context_length() explicitly treats get_model_context_length() as authoritative for provider caps (hermes_cli/model_switch.py:689-715), so this can recommend the vendor-wide context instead of the effective one. The helper also cannot receive custom_providers.
  • hermes_cli/model_switch.py:155 recommends /context <n>, but current main has no /context command definition or handler.
  • The gateway handler has moved to gateway/slash_commands.py:1399; the current TUI persistence path at tui_gateway/server.py:2795-2812 also needs equivalent handling if this is to cover Hermes' /model surfaces.

Suggested changes

  • Rework the helper around the provider-aware resolver with config_context_length=None, and pass compatible custom-provider data.
  • Point users to an existing configuration workflow, or implement /context as a separate command.
  • Cover provider-capped and custom-provider context values in regression tests.

Automated hermes-sweeper review.

return ""

target_ctx = 0
if result.model_info and isinstance(result.model_info.context_window, int):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModelInfo.context_window can be the vendor-wide catalog value rather than this provider's effective cap. Resolve through the same provider-aware path as current resolve_display_context_length() (and include custom-provider overrides) before composing a recommended replacement.


return (
f"config.yaml context_length ({config_ctx:,}) doesn't match this model. "
f"Run /context {target_ctx} to update, or keep the current value if intentional."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/context is not a registered Hermes slash command on current main, so this remediation cannot be followed. Please point to an existing supported config workflow or add the command separately.

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

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Warn on context_length mismatch after /model --global switch

3 participants