fix(model): salvage model/provider resolution PRs #6860 #6844 #6863 #6943 - #7187
Merged
Conversation
Port from anomalyco/opencode#21355: Alibaba's DashScope API returns a unique throttling message ('Request rate increased too quickly...') that doesn't match standard rate-limit patterns ('rate limit', 'too many requests'). This caused Alibaba errors to fall through to the 'unknown' category rather than being properly classified as rate_limit with appropriate backoff/rotation. Add 'rate increased too quickly' to _RATE_LIMIT_PATTERNS and test with the exact error message observed from the Alibaba provider.
When switching models at runtime, the config_context_length override was not being passed to the new context compressor instance. This meant the user-specified context length from config.yaml was lost after a model switch. - Store _config_context_length on AIAgent instance during __init__ - Pass _config_context_length when creating new ContextCompressor in switch_model - Add test to verify config_context_length is preserved across model switches Fixes: quando estamos alterando o modelo não está alterando o tamanho do contexto
… credential check When opencode-go API key is set, it should appear in the /model list. The provider was already in PROVIDER_TO_MODELS_DEV and PROVIDER_REGISTRY, so it appears via Part 1 (built-in source). Also fixes a potential issue in Part 2 (HERMES_OVERLAYS) where providers with auth_type=api_key but no extra_env_vars would not be detected: - Now also checks api_key_env_vars from PROVIDER_REGISTRY for api_key auth_type - Add test verifying opencode-go appears when OPENCODE_GO_API_KEY is set
Previously, _model_flow_named_custom() returned immediately when a saved model existed, making it impossible to switch models on multi-model endpoints (OpenRouter, vLLM clusters, etc.). Now the function always probes the endpoint and shows the selection menu with the current model pre-selected and marked '(current)'. Falls back to the saved model if endpoint probing fails. Fixes #6862
Covers: probe always called, model switch works, probe failure fallback, first-time flow unchanged.
…r tests fetch_api_models is imported locally inside _model_flow_named_custom from hermes_cli.models, not defined as a module-level attribute of hermes_cli.main. Patch the source module so the local import picks up the mock. Also force simple_term_menu ImportError so tests reliably use the input() fallback path regardless of environment. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
This was referenced Apr 10, 2026
This was referenced Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Salvage of 4 model/provider PRs. Contributor authorship preserved.
Cherry-picked:
fix: add Alibaba/DashScope rate-limit pattern to error classifier #6860 (teknium1) — Add "rate increased too quickly" to
_RATE_LIMIT_PATTERNSfor Alibaba/DashScope API. +17/-0.fix: preserve config_context_length when switching models #6844 (rarf) — Two fixes: (a) Store
_config_context_lengthon AIAgent so user's context_length override survivesswitch_model(), (b) Fix credential detection for opencode-go providers by also checkingPROVIDER_REGISTRY.api_key_env_vars. +118/-1.fix: always show model selection for multi-model custom providers #6863 (r266-tech) — Remove early-return in
_model_flow_named_custom()that skipped the model selection menu after first use. Now always probes /models API and shows menu for multi-model custom providers. Includes author's own test fix commit. +149/-27.fix(model): normalize native provider-prefixed model ids #6943 (aquaright1) — Replace
_strip_vendor_prefix()with_strip_matching_provider_prefix()that only strips when prefix matches the target provider. Fixes "google/gemini-2.5-pro" being wrongly stripped to "gemini-2.5-pro" when sent to anthropic. Adds normalization in AIAgent.init, fallback activation, and auxiliary client routing. +300/-21.Skipped:
Test results