Skip to content

fix(model): unify context-length resolution across runtime and /model display#12316

Closed
leavrcn wants to merge 1 commit into
NousResearch:mainfrom
leavrcn:fix/model-context-length-unification
Closed

fix(model): unify context-length resolution across runtime and /model display#12316
leavrcn wants to merge 1 commit into
NousResearch:mainfrom
leavrcn:fix/model-context-length-unification

Conversation

@leavrcn

@leavrcn leavrcn commented Apr 18, 2026

Copy link
Copy Markdown

Summary

  • centralize config-driven context-length resolution into a shared module so runtime, CLI, and gateway all use the same override logic
  • return a unified display context length from /model switching so custom provider overrides stay consistent even when models.dev metadata is incomplete
  • add regression coverage plus plan/progress docs for the refactor and validation work

Testing

  • source venv/bin/activate && python -m pytest tests/agent/test_context_length_config.py tests/hermes_cli/test_model_switch_custom_providers.py tests/run_agent/test_switch_model_context.py tests/run_agent/test_invalid_context_length_warning.py tests/gateway/test_model_command_custom_providers.py tests/gateway/test_session_info.py -q
  • source venv/bin/activate && python -m pytest tests/hermes_cli/test_model_switch_custom_providers.py tests/hermes_cli/test_model_switch_opencode_anthropic.py tests/hermes_cli/test_model_switch_copilot_api_mode.py tests/hermes_cli/test_model_switch_variant_tags.py tests/hermes_cli/test_custom_provider_model_switch.py tests/hermes_cli/test_user_providers_model_switch.py -q
  • source venv/bin/activate && python -m pytest tests/gateway/test_model_switch_persistence.py tests/gateway/test_session_model_override_routing.py tests/gateway/test_session_model_reset.py tests/gateway/test_model_command_custom_providers.py tests/gateway/test_session_info.py -q
  • source venv/bin/activate && python -m pytest tests/run_agent/test_plugin_context_engine_init.py tests/run_agent/test_switch_model_context.py tests/run_agent/test_invalid_context_length_warning.py tests/cli/test_cli_context_warning.py -q

@mxnstrexgl

Copy link
Copy Markdown

⚠️ Automated scan: skipped deep review. This PR is 7,723+ additions (model context-length unification) — too large for automated review. Recommend manual review focusing on: provider credential handling, config parsing changes, model resolution logic.

@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery labels Apr 23, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Overlaps with #11437 and #8786 — all three unify context-length resolution across display and runtime paths.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for submitting this refactor, @leavrcn! The core goals of this PR have since been addressed directly on main by maintainer commits — closing as implemented.

What landed on main:

The approach on main achieves the same unification without adding a new agent/context_length_config.py module — the logic lives in the existing hermes_cli/config.py and hermes_cli/model_switch.py instead.

This is an automated hermes-sweeper review.

@teknium1 teknium1 closed this Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants