Repository navigation
fix(providers): support GPT-5 models on GitHub Copilot backend - #3380
Merged
Merged
Conversation
…models
Calling GitHub Copilot with `gpt-5.*` / `o*` models (e.g.
`github_copilot/gpt-5.4`, `github_copilot/gpt-5.4-mini`) failed with a
chain of misleading errors:
1. `Unsupported parameter: 'max_tokens' is not supported with this
model. Use 'max_completion_tokens' instead.`
2. `model "gpt-5.4-mini" is not accessible via the /chat/completions
endpoint` (`unsupported_api_for_model`).
3. `The requested model is not supported.` (`model_not_supported`)
even after routing to /responses.
Root causes (each one masked the next):
* The `github_copilot` ProviderSpec did not opt into
`supports_max_completion_tokens`, so `_build_kwargs` always sent the
legacy `max_tokens` parameter that GPT-5/o-series reject.
* `_should_use_responses_api` was hard-gated to
`spec.name == "openai"` plus a direct-OpenAI base URL, so the
GitHub Copilot backend always went through /chat/completions even
for models the Copilot gateway exposes only via /responses
(e.g. `gpt-5.4-mini`).
* When /responses did fail on github_copilot, the existing
"compatibility marker" heuristic silently fell back to
/chat/completions — which can never succeed for these models — so
the real upstream error was hidden.
* `_build_responses_body` did not honour `spec.strip_model_prefix`,
so the request body sent `model="github_copilot/gpt-5.4-mini"`
(with the routing prefix), which the Copilot gateway rejects with
`model_not_supported`. (`_build_kwargs` already stripped it; this
branch was missed.)
Fix:
* registry.py: set `supports_max_completion_tokens=True` on the
`github_copilot` spec so requests use `max_completion_tokens`.
* openai_compat_provider.py:
- `_should_use_responses_api` now also allows the
`github_copilot` spec, and skips the direct-OpenAI base check
for it (the Copilot gateway is its own base URL).
- `_build_responses_body` now strips the model routing prefix
when `spec.strip_model_prefix` is set, matching `_build_kwargs`.
- `chat` / `chat_stream` no longer fall back from /responses to
/chat/completions on the `github_copilot` spec: the fallback
cannot succeed for GPT-5/o-series and would mask the real
gateway error.
Tests:
* tests/cli/test_commands.py: switched the
`test_github_copilot_provider_refreshes_client_api_key_before_chat`
fixture model from `gpt-5.1` to `gpt-4` so it continues to exercise
the /chat/completions code path it was designed for (gpt-5.1 now
correctly routes to /responses on github_copilot).
* `pytest tests/providers/ tests/cli/test_commands.py` — 314 passed.
* Verified end-to-end against the live Copilot gateway with both
`github_copilot/gpt-5.4` and `github_copilot/gpt-5.4-mini`.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
gongpx20069
force-pushed
the
fix/github-copilot-gpt5-support
branch
from
April 22, 2026 06:28
db3b8c5 to
dd26b44
Compare
Contributor
Author
|
Hi @Re-bin could you help review this PR? the nanobot won't work by gpt-5x models of gh copilot provider without the fix. Thanks |
Re-bin
added a commit
that referenced
this pull request
Apr 22, 2026
…port fix(providers): support GPT-5 models on GitHub Copilot backend Co-authored-by: gongpx20069 <21985921+gongpx20069@users.noreply.github.com>
MaoChen1980
pushed a commit
to MaoChen1980/nanobot-mg
that referenced
this pull request
May 18, 2026
…5-support fix(providers): support GPT-5 models on GitHub Copilot backend Co-authored-by: gongpx20069 <21985921+gongpx20069@users.noreply.github.com>
StefanoParadisi
pushed a commit
to StefanoHernandez/nanobot
that referenced
this pull request
Oct 16, 2026
…5-support fix(providers): support GPT-5 models on GitHub Copilot backend Co-authored-by: gongpx20069 <21985921+gongpx20069@users.noreply.github.com>
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.
Problem
Calling GitHub Copilot with
gpt-5.*/o*models (e.g.github_copilot/gpt-5.4,github_copilot/gpt-5.4-mini) failed with a chain of misleading errors:Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.model "gpt-5.4-mini" is not accessible via the /chat/completions endpoint(unsupported_api_for_model)The requested model is not supported.(model_not_supported) even after routing to/responsesEach error masked the next, making it impossible to use any GPT-5/o-series model through the GitHub Copilot backend.
Root causes
max_tokensparameter: Thegithub_copilotProviderSpec did not opt intosupports_max_completion_tokens, so_build_kwargsalways sent the legacymax_tokensparameter that GPT-5/o-series reject._should_use_responses_apiwas hard-gated tospec.name == "openai"plus a direct-OpenAI base URL, so the GitHub Copilot backend always went through/chat/completionseven for models the Copilot gateway exposes only via/responses(e.g.gpt-5.4-mini,gpt-5.*-codex)./responsesfailed ongithub_copilot, the existing "compatibility marker" heuristic silently fell back to/chat/completions— which can never succeed for these models — so the real upstream error was hidden./responses:_build_responses_bodydid not honourspec.strip_model_prefix, so the request body sentmodel="github_copilot/gpt-5.4-mini"(with the routing prefix), which the Copilot gateway rejects withmodel_not_supported. (_build_kwargsalready stripped it; this branch was missed.)Fix
nanobot/providers/registry.pysupports_max_completion_tokens=Trueon thegithub_copilotspec so requests usemax_completion_tokens.nanobot/providers/openai_compat_provider.py_should_use_responses_apinow also allows thegithub_copilotspec, and skips the direct-OpenAI base check for it (the Copilot gateway is its own base URL)._build_responses_bodynow strips the model routing prefix whenspec.strip_model_prefixis set, matching_build_kwargs.chat/chat_streamno longer fall back from/responsesto/chat/completionson thegithub_copilotspec: the fallback cannot succeed for GPT-5/o-series and would mask the real gateway error.Tests
tests/cli/test_commands.py: switched thetest_github_copilot_provider_refreshes_client_api_key_before_chatfixture model fromgpt-5.1togpt-4so it continues to exercise the/chat/completionscode path it was designed for (gpt-5.1now correctly routes to/responsesongithub_copilot).pytest tests/providers/ tests/cli/test_commands.py— 314 passed.Verified end-to-end against the live Copilot gateway with all GPT-5 family models:
gpt-5-minigpt-5.2gpt-5.4gpt-5.4-minigpt-5.2-codexgpt-5.3-codex