Skip to content

fix(copilot): use target_model not config default for api_mode resolution - #60431

Closed
CharlesMcquade wants to merge 1 commit into
NousResearch:mainfrom
CharlesMcquade:fix/copilot-gpt5-responses-api
Closed

fix(copilot): use target_model not config default for api_mode resolution#60431
CharlesMcquade wants to merge 1 commit into
NousResearch:mainfrom
CharlesMcquade:fix/copilot-gpt5-responses-api

Conversation

@CharlesMcquade

Copy link
Copy Markdown
Contributor

Problem

When selecting GPT-5.5 via Copilot as the primary model from the WebUI dropdown, every API call fails with:

HTTP 400: model gpt-5.5 is not accessible via the /chat/completions endpoint

GPT-5.x models on Copilot require the /responses endpoint (codex_responses API mode), but the request is sent to /chat/completions instead.

Root Cause

_copilot_runtime_api_mode() in runtime_provider.py reads model_cfg.get("default") — the persisted config.yaml default model (e.g. deepseek-ai/DeepSeek-V4-Flash) — instead of the actual target model (gpt-5.5) when deciding which API endpoint to use.

The WebUI correctly passes target_model to resolve_runtime_provider(), but _copilot_runtime_api_mode() does not accept or use it. Since the config default is not a GPT-5 model, _should_use_copilot_responses_api() returns False, and the API mode resolves to chat_completions.

The fallback path (try_activate_fallback in chat_completion_helpers.py) is unaffected because it uses _provider_model_requires_responses_api() with the correct model name — which is why GPT-5.5 works as a fallback but fails as a primary model selected from the WebUI.

Fix

Pass target_model through _copilot_runtime_api_mode() at both call sites (pool entry path at line 446 and non-pool path at line 2003) and prefer it over model_cfg.get("default") when determining the API mode.

Reproduction

  1. Set config.yaml default model to a non-GPT-5 model (e.g. deepseek-ai/DeepSeek-V4-Flash on custom:wandb)
  2. In the WebUI, select @copilot:gpt-5.5 from the model dropdown
  3. Send a message — HTTP 400 from Copilot
  4. Falls back through the chain (claude-sonnet-5 on copilot also fails if not in catalog, then to local MLX which may also fail)

Testing

  • 218 copilot-related tests pass (1 pre-existing failure in test_copilot_acp_client unrelated to this change — HERMES_REAL_HOME env var issue)
  • Simulated the fix: with target_model="gpt-5.5" and config default deepseek-ai/DeepSeek-V4-Flash, the API mode now correctly resolves to codex_responses

Note: This was authored using the GitHub Copilot commit email per the AGENTS.md fork conventions.

…tion

When the WebUI selects a copilot model (e.g. gpt-5.5) via the dropdown,
resolve_runtime_provider receives it as target_model. However,
_copilot_runtime_api_mode was reading model_cfg.get('default') — the
persisted config.yaml default (e.g. deepseek-v4) — instead of the
actual target model. This caused GPT-5.x models to be routed to
/chat/completions instead of the /responses endpoint, resulting in
HTTP 400: 'model "gpt-5.5" is not accessible via the /chat/completions
endpoint'.

The fallback path (try_activate_fallback in chat_completion_helpers.py)
was unaffected because it uses _provider_model_requires_responses_api()
with the correct model name, which is why gpt-5.5 worked as a fallback
but failed as a primary model selected from the WebUI.

Fix: pass target_model through _copilot_runtime_api_mode at both call
sites (pool entry path and non-pool path) and prefer it over
model_cfg.get('default') when determining the API mode.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard provider/copilot GitHub Copilot (ACP + Chat) duplicate This issue or pull request already exists labels Jul 7, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #60294 -- both fix _copilot_runtime_api_mode in hermes_cli/runtime_provider.py by threading target_model through and preferring it over the stale model_cfg["default"] (so GPT-5.x on Copilot routes to /responses instead of 400-ing on /chat/completions). Same function, same mechanism, same file scope; #60294 is the earlier open PR (created ~5h before this). Related: #60086 (models.py/slot-level) and #32308 (broader superset). Tracking the fix in #60294.

@CharlesMcquade

Copy link
Copy Markdown
Contributor Author

Closing as duplicate of #60294

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists provider/copilot GitHub Copilot (ACP + Chat) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants