fix(opencode): preserve /v1 in base_url when switching from anthropic_messages to chat_completions models - #16885
Closed
quannon wants to merge 1 commit into
Closed
fix(opencode): preserve /v1 in base_url when switching from anthropic_messages to chat_completions models#16885quannon wants to merge 1 commit into
quannon wants to merge 1 commit into
Conversation
…_messages to chat_completions models In runtime_provider.py, the non-pool API-key providers block was applying stale configured_mode (e.g. anthropic_messages from a minimax default) before the opencode-go/zen api_mode detection could run, causing /v1 to be stripped when switching to deepseek-v4-flash (which needs chat_completions). Fix by promoting opencode-go/zen detection to run unconditionally for opencode providers, bypassing the configured_mode override. Same change applied to _resolve_runtime_from_pool_entry for consistency. Fixes: NousResearch#16878
Contributor
|
Thanks for the fix, @quannon! The bug you identified is real and your analysis of the root cause is exactly right. Unfortunately, an independent fix for the same issue landed on
The fix also explicitly cites #16878. Since the same change is already live in the latest release, this PR is superseded. This review was performed by the automated hermes-sweeper. |
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
When using the opencode-go provider with a config default model that uses
anthropic_messagesmode (e.g.minimax-m2.7) and switching to achat_completionsmodel (e.g.deepseek-v4-flash) via the/modelslash command, thebase_urlloses/v1, resulting in an HTTP 404 error.Fixes: #16878
Root Cause
In
runtime_provider.py, the non-pool "API-key providers" block (~lines 1213-1237), when the credential pool is exhausted:configured_mode = _parse_api_mode(model_cfg.get("api_mode"))reads"anthropic_messages"from the stale configelif, so it never ran whenconfigured_modewas truthyFix Applied
Promoted opencode-go/zen detection to an explicit
ifblock that runs before theconfigured_modeoverride, so it always correctly detects api_mode based on the target model.Same change applied to
_resolve_runtime_from_pool_entryfor consistency.Verification
Tests
12/12 passing:
python -m pytest tests/hermes_cli/test_model_switch_opencode_anthropic.py -v