mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-28 06:51:16 +08:00
fix: recompute Copilot api_mode after model switch
Recomputes GitHub Copilot api_mode from the selected model in the shared /model switch path. Before this change, Copilot could carry a stale codex_responses mode forward from a GPT-5 selection into a later Claude model switch, causing unsupported_api_for_model errors. Cherry-picked from #10533 by @helix4u with: - Comment specificity (Provider-specific → Copilot api_mode override) - Fix pre-existing duplicate opencode-go in set literal - Extract test mock helper to reduce duplication - Add GPT-5 → GPT-5 regression test (keeps codex_responses)
This commit is contained in:
@@ -457,6 +457,7 @@ def switch_model(
|
||||
ModelSwitchResult with all information the caller needs.
|
||||
"""
|
||||
from hermes_cli.models import (
|
||||
copilot_model_api_mode,
|
||||
detect_provider_for_model,
|
||||
validate_requested_model,
|
||||
opencode_model_api_mode,
|
||||
@@ -714,8 +715,12 @@ def switch_model(
|
||||
if validation.get("corrected_model"):
|
||||
new_model = validation["corrected_model"]
|
||||
|
||||
# --- Copilot api_mode override ---
|
||||
if target_provider in {"copilot", "github-copilot"}:
|
||||
api_mode = copilot_model_api_mode(new_model, api_key=api_key)
|
||||
|
||||
# --- OpenCode api_mode override ---
|
||||
if target_provider in {"opencode-zen", "opencode-go", "opencode", "opencode-go"}:
|
||||
if target_provider in {"opencode-zen", "opencode-go", "opencode"}:
|
||||
api_mode = opencode_model_api_mode(target_provider, new_model)
|
||||
|
||||
# --- Determine api_mode if not already set ---
|
||||
@@ -1098,5 +1103,3 @@ def list_authenticated_providers(
|
||||
results.sort(key=lambda r: (not r["is_current"], -r["total_models"]))
|
||||
|
||||
return results
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user