Skip to content

fix(cli): honor custom context lengths in model switch display - #19034

Closed
dinedal wants to merge 1 commit into
NousResearch:mainfrom
dinedal:fix/model-context-display-custom-providers
Closed

dinedal wants to merge 1 commit into
NousResearch:mainfrom
dinedal:fix/model-context-display-custom-providers

Conversation

@dinedal

@dinedal dinedal commented May 3, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the CLI /model confirmation display so configured local/custom-provider context lengths are honored consistently. The display resolver now checks explicit config and matching custom_providers[].models.<model>.context_length overrides before falling back to provider-aware metadata or models.dev.

This also threads custom_providers through both CLI confirmation paths: typed /model ... and picker/apply-result.

Related open PRs found before submission: #18777 and #18844 cover broader custom-provider context paths; this PR is the narrow CLI confirmation-display patch on current upstream/main.

Related Issue

Fixes #15779

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • hermes_cli/model_switch.py: give resolve_display_context_length() explicit config/custom-provider precedence before metadata fallback.
  • cli.py: pass loaded custom_providers into direct and picker /model confirmation display paths.
  • tests/hermes_cli/test_model_switch_context_display.py: cover config override, matching custom-provider override, non-matching custom-provider fallback, and existing provider-aware behavior.
  • tests/hermes_cli/test_apply_model_switch_result_context.py: cover picker confirmation display with custom-provider context length.

How to Test

  1. Configure a local/custom OpenAI-compatible endpoint with custom_providers[].models.<model>.context_length.
  2. Switch to that model with typed /model <name> --provider <provider> and verify the confirmation shows the configured context.
  3. Switch to that model through the interactive /model picker and verify the same configured context appears.

Automated tests run with the repo-required wrapper, not direct pytest:

  • scripts/run_tests.sh tests/hermes_cli/test_model_switch_context_display.py
  • scripts/run_tests.sh tests/hermes_cli/test_apply_model_switch_result_context.py tests/hermes_cli/test_model_switch_custom_providers.py tests/run_agent/test_switch_model_context.py

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS (aarch64), Python 3.12.8

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

N/A

Screenshots / Logs

Focused test results:

  • tests/hermes_cli/test_model_switch_context_display.py: 9 passed
  • tests/hermes_cli/test_apply_model_switch_result_context.py tests/hermes_cli/test_model_switch_custom_providers.py tests/run_agent/test_switch_model_context.py: 23 passed

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard area/config Config system, migrations, profiles labels May 3, 2026
@alt-glitch

Copy link
Copy Markdown

Likely duplicate of #15844 (merged) which already threads custom_providers through switch_model/resolve_display_context_length. Also overlaps with open PRs #18777 and #18844. Narrower CLI-display-only patch — check if #15844 already covers this path.

@alt-glitch

Copy link
Copy Markdown

Likely duplicate of #15844 (merged).

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 P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: /model switch to named custom provider ignores custom_providers model context_length

2 participants