Skip to content

fix(copilot): route responses-only models across runtimes - #88538

Open
intellectronica wants to merge 2 commits into
NousResearch:mainfrom
intellectronica:fix/copilot-responses-api
Open

fix(copilot): route responses-only models across runtimes#88538
intellectronica wants to merge 2 commits into
NousResearch:mainfrom
intellectronica:fix/copilot-responses-api

Conversation

@intellectronica

@intellectronica intellectronica commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • route Copilot models advertised as /responses-only through codex_responses, including Grok 4.6
  • apply the same catalog-aware decision to primary agent initialisation, auxiliary clients, and fallback activation
  • preserve Copilot Claude models on the OpenAI-compatible chat path

Provenance and related work

This salvages the original implementation from #58835 by cherry-picking its commit, preserving Anatoly Svichkarev's authorship, then addresses the maintainer review on that PR: non-GPT Responses-only models also need catalog-aware routing in the auxiliary and fallback activation paths.

Related overlapping PRs: #74377, #85224, #86075. This branch differs by covering all three runtime paths with regression tests while retaining current-main Claude transport behaviour.

Problem

Copilot's live model catalog advertises Grok 4.6 with:

{"supported_endpoints": ["/responses"]}

Hermes classified Copilot transport primarily from the GPT-5 model-name heuristic. Non-GPT Responses-only models therefore used /chat/completions and failed with:

HTTP 400: model "grok-4.6" is not accessible via the /chat/completions endpoint

The primary model helper, auxiliary client wrapper, and fallback activation each made that decision separately, so fixing only copilot_model_api_mode() left sibling paths broken.

Approach

  • make copilot_model_api_mode() honour /responses when /chat/completions is absent
  • pass the active credential into the shared Copilot resolver during agent initialisation and fallback activation
  • use the same resolver before auxiliary request headers are constructed, then wrap Responses-only models with CodexAuxiliaryClient
  • keep GPT-5 heuristics and explicit API-mode overrides unchanged

Verification

  • regression tests were added before the fix and failed on current main in all three paths
  • scripts/run_tests.sh across six affected test files: 182 passed, 0 failed
  • Ruff checks and git diff --check: passed
  • a live end-to-end Copilot request could not be completed while GitHub Status reported a Copilot major outage and the token-exchange endpoint returned HTTP 503; the runtime failure itself is captured in existing Hermes logs and the regression tests use the catalog contract

Risk

Low and provider-scoped. Catalog metadata only upgrades a model when /responses is explicitly present and /chat/completions is absent. Chat-capable Claude and Gemini models retain their current transport.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard provider/copilot GitHub Copilot (ACP + Chat) labels Aug 17, 2026
@intellectronica
intellectronica force-pushed the fix/copilot-responses-api branch from c796300 to 3cc8677 Compare August 21, 2026 13:59
@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference; please use your judgment.

The routing principle is right: the vendor/name pattern check stops being the sole authority, and the catalog's supported_endpoints decides — with two deliberate guardrails kept ahead of it (GPT-5 pattern first, Copilot-Claude pinned to chat regardless of what the catalog lists). Moving the transport resolution before header construction in _wrap_if_needed fixes a real interleaving bug (catalog discovery issuing its own Copilot request after headers were built), threading api_key into _provider_model_requires_responses_api means main-line and fallback activation now share one catalog-aware decision instead of the fallback silently downgrading to the name heuristic, and the tests cover both directions that matter: responses-only Grok upgrades everywhere (aux wrapper, primary, and fallback activation), while Claude stays on chat even when the catalog lists /responses.

  1. hermes_cli/models.py:copilot_model_api_mode (dual-endpoint branch untested) — the upgrade fires only when /responses ∈ endpoints AND /chat/completions ∉ endpoints; nothing pins the second conjunct. Why it matters: a model advertising both endpoints must stay on chat_completions (cheaper path, existing behavior), and a future edit dropping the not in clause would flip every dual-endpoint model to Responses with all current tests green. Suggestion: add the parametrized neighbor — supported_endpoints: ["/responses", "/chat/completions"]chat_completions — next to the two existing catalog cases.

Nit: the pre-existing Claude/chat comment block immediately below the new catalog fallback now explains the same invariant the new early-return above it already enforces; folding them into one statement (or deleting the stale half) would keep the function's contract stated once.

— Reviewed by Hermes AI reviewer (reviewer-f2)

Add the catalog neighbour that advertises both /responses and
/chat/completions so the upgrade's second conjunct cannot be
dropped unnoticed. Fold the duplicated Claude/chat comment
into the early-return.
@intellectronica

Copy link
Copy Markdown
Contributor Author

Addressed in 7d31824.

  • added the dual-endpoint neighbour: supported_endpoints: ["/responses", "/chat/completions"]chat_completions
  • folded the duplicated Claude/chat comment into the early-return so the invariant is stated once

scripts/run_tests.sh on the six Copilot routing files: 180 passed, 0 failed.

@munim

munim commented Aug 23, 2026

Copy link
Copy Markdown

@alt-glitch when can we expect this to be merged? its actually blocking copilot grok users.

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

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard 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.

4 participants