fix: github-copilot Responses API auto-selection and error preservation#2942
Conversation
|
❌ PR Review Failed — The review agent encountered an error and could not complete the review. View logs. |
aheritier
left a comment
There was a problem hiding this comment.
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-5and Codex variants routing to/responses. - Older/chat-only Copilot models staying on
/chat/completions. - Explicit
openai_chatcompletionsoverriding 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: successlint: successlicense-check: successbuild-image: successPR Review: successsave-context: success
No blocking findings.
GitHub Copilot returns HTTP 400 Bad Request when newer models like gpt-5 and Codex are sent to the legacy
/chat/completionsendpoint, 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.SupportsResponsesAPIso new models are picked up by naming convention. It also wiresoaistream.ErrorBodyMiddlewareinto 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_typeoverride behavior, and error-body preservation. This relates to the earlier Copilot header fix #2471.Fixes #2885