Skip to content

fix: github-copilot Responses API auto-selection and error preservation#2942

Merged
dgageot merged 2 commits into
docker:mainfrom
dgageot:board/e5841bf149130c7a
Jun 2, 2026
Merged

fix: github-copilot Responses API auto-selection and error preservation#2942
dgageot merged 2 commits into
docker:mainfrom
dgageot:board/e5841bf149130c7a

Conversation

@dgageot
Copy link
Copy Markdown
Member

@dgageot dgageot commented Jun 1, 2026

GitHub Copilot returns HTTP 400 Bad Request when newer models like gpt-5 and Codex are sent to the legacy /chat/completions endpoint, since Copilot proxies the same OpenAI models but has a different set of supported endpoints. This change extends the Responses API auto-selection logic to the github-copilot provider so that models are routed to the correct endpoint based on their capabilities, not a hardcoded allow-list.

The fix extends the OpenAI client's endpoint auto-selection to the github-copilot provider, driven by modelinfo.SupportsResponsesAPI so new models are picked up by naming convention. It also wires oaistream.ErrorBodyMiddleware into the direct OpenAI client path to preserve provider error bodies—like Copilot's bare "400 Bad Request"—instead of discarding them, so users see meaningful error messages.

Comprehensive tests verify endpoint selection for different model families, explicit api_type override behavior, and error-body preservation. This relates to the earlier Copilot header fix #2471.

Fixes #2885

@dgageot dgageot requested a review from a team as a code owner June 1, 2026 10:23
@aheritier aheritier added area/providers For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.) area/providers/openai For features/issues/fixes related to the usage of OpenAI models kind/fix PR fixes a bug (maps to fix: commit prefix) labels Jun 1, 2026
@docker-agent
Copy link
Copy Markdown

PR Review Failed — The review agent encountered an error and could not complete the review. View logs.

@joshbarrington
Copy link
Copy Markdown
Contributor

@dgageot does this also close: #2303 ?

Copy link
Copy Markdown
Contributor

@aheritier aheritier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

I reviewed the Copilot Responses API auto-selection, explicit api_type override behavior, direct-client error-body preservation, docs, and tests. The implementation keeps explicit provider_opts.api_type precedence before auto-selection, extends automatic Responses routing only to openai and github-copilot, and relies on the existing modelinfo.SupportsResponsesAPI capability predicate rather than adding a Copilot-specific model allow-list.

The new tests cover:

  • Copilot gpt-5 and Codex variants routing to /responses.
  • Older/chat-only Copilot models staying on /chat/completions.
  • Explicit openai_chatcompletions overriding auto-selection.
  • Plain-text provider error bodies being surfaced to callers.

Security-wise, token resolution and BaseURL handling are unchanged, and Copilot header handling remains centralized through the existing sanitized header path.

CI is green for head SHA ffa07cd5aa7eb3f7c85ea85241eec78718dcb0dd:

  • build-and-test: success
  • lint: success
  • license-check: success
  • build-image: success
  • PR Review: success
  • save-context: success

No blocking findings.

@dgageot dgageot merged commit b46aee4 into docker:main Jun 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/providers/openai For features/issues/fixes related to the usage of OpenAI models area/providers For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.) kind/fix PR fixes a bug (maps to fix: commit prefix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

github-copilot provder is not working Ability to set the Copilot-Integration-Id header for github-copilot provider

4 participants