fix: add Azure channel support for /v1/responses/compact URL routing - #4149
Conversation
The Azure channel's GetRequestURL method only handled RelayModeResponses
but missed RelayModeResponsesCompact. This caused compact requests to
fall through to the generic deployments URL pattern, producing an
incorrect path that Azure returns 404 for.
This fix extends the existing responses API special handling to also
cover the compact mode, appending /compact to the subUrl when the relay
mode is ResponsesCompact.
Affected URLs (before → after):
- Normal Azure: /openai/deployments/{model}/responses/compact → /openai/v1/responses/compact
- cognitiveservices: same pattern → /openai/responses/compact
- Custom AzureResponsesVersion: properly respected for compact too
There was a problem hiding this comment.
Pull request overview
Fixes Azure OpenAI URL generation for the /v1/responses/compact endpoint by ensuring Azure channels route compaction requests to the correct “responses API” path (instead of the deployments-based path that Azure 404s).
Changes:
- Extend Azure
GetRequestURLresponses-API special-case to includeRelayModeResponsesCompact. - Append
/compactto the Azure responses sub-path when in compact mode. - Preserve existing behavior for standard
/v1/responsesand non-responses endpoints.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe change extends Azure OpenAI responses request URL construction to handle a new relay mode ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
有Azure支持的文档地址吗?这个compact之前Azure是不支持的 |
这是 Azure 官方文档中关于 Compact a response 端点的说明: 📄 Azure OpenAI Responses API - Compact a response 以及 OpenAI 官方 API 参考文档: Compact 端点(POST /responses/compact)是 Responses API 的一部分。Azure 通过 /openai/v1/responses/compact(或 cognitiveservices.azure.com 域名下的 /openai/responses/compact)提供支持,URL 规则与 /openai/v1/responses 一致。 我们已在实际的 Azure OpenAI 资源上验证了这个修复,compact 请求能够正确路由并返回有效的 response.compaction 响应对象。 |
…uantumNous#4149) The Azure channel's GetRequestURL method only handled RelayModeResponses but missed RelayModeResponsesCompact. This caused compact requests to fall through to the generic deployments URL pattern, producing an incorrect path that Azure returns 404 for. This fix extends the existing responses API special handling to also cover the compact mode, appending /compact to the subUrl when the relay mode is ResponsesCompact. Affected URLs (before → after): - Normal Azure: /openai/deployments/{model}/responses/compact → /openai/v1/responses/compact - cognitiveservices: same pattern → /openai/responses/compact - Custom AzureResponsesVersion: properly respected for compact too Co-authored-by: 彭俊杰 <pengjunjie@onero.com>
…(#4149)
The Azure channel's GetRequestURL method only handled RelayModeResponses
but missed RelayModeResponsesCompact. This caused compact requests to
fall through to the generic deployments URL pattern, producing an
incorrect path that Azure returns 404 for.
This fix extends the existing responses API special handling to also
cover the compact mode, appending /compact to the subUrl when the relay
mode is ResponsesCompact.
Affected URLs (before → after):
- Normal Azure: /openai/deployments/{model}/responses/compact → /openai/v1/responses/compact
- cognitiveservices: same pattern → /openai/responses/compact
- Custom AzureResponsesVersion: properly respected for compact too
Co-authored-by: 彭俊杰 <pengjunjie@onero.com>
(cherry picked from commit 3ab65a822174d1c984c61fa1a6f45feaee80ae56)
…uantumNous#4149) The Azure channel's GetRequestURL method only handled RelayModeResponses but missed RelayModeResponsesCompact. This caused compact requests to fall through to the generic deployments URL pattern, producing an incorrect path that Azure returns 404 for. This fix extends the existing responses API special handling to also cover the compact mode, appending /compact to the subUrl when the relay mode is ResponsesCompact. Affected URLs (before → after): - Normal Azure: /openai/deployments/{model}/responses/compact → /openai/v1/responses/compact - cognitiveservices: same pattern → /openai/responses/compact - Custom AzureResponsesVersion: properly respected for compact too Co-authored-by: 彭俊杰 <pengjunjie@onero.com>
…uantumNous#4149) The Azure channel's GetRequestURL method only handled RelayModeResponses but missed RelayModeResponsesCompact. This caused compact requests to fall through to the generic deployments URL pattern, producing an incorrect path that Azure returns 404 for. This fix extends the existing responses API special handling to also cover the compact mode, appending /compact to the subUrl when the relay mode is ResponsesCompact. Affected URLs (before → after): - Normal Azure: /openai/deployments/{model}/responses/compact → /openai/v1/responses/compact - cognitiveservices: same pattern → /openai/responses/compact - Custom AzureResponsesVersion: properly respected for compact too Co-authored-by: 彭俊杰 <pengjunjie@onero.com> (cherry picked from commit 3ab65a8)
…uantumNous#4149) The Azure channel's GetRequestURL method only handled RelayModeResponses but missed RelayModeResponsesCompact. This caused compact requests to fall through to the generic deployments URL pattern, producing an incorrect path that Azure returns 404 for. This fix extends the existing responses API special handling to also cover the compact mode, appending /compact to the subUrl when the relay mode is ResponsesCompact. Affected URLs (before → after): - Normal Azure: /openai/deployments/{model}/responses/compact → /openai/v1/responses/compact - cognitiveservices: same pattern → /openai/responses/compact - Custom AzureResponsesVersion: properly respected for compact too Co-authored-by: 彭俊杰 <pengjunjie@onero.com>
…uantumNous#4149) The Azure channel's GetRequestURL method only handled RelayModeResponses but missed RelayModeResponsesCompact. This caused compact requests to fall through to the generic deployments URL pattern, producing an incorrect path that Azure returns 404 for. This fix extends the existing responses API special handling to also cover the compact mode, appending /compact to the subUrl when the relay mode is ResponsesCompact. Affected URLs (before → after): - Normal Azure: /openai/deployments/{model}/responses/compact → /openai/v1/responses/compact - cognitiveservices: same pattern → /openai/responses/compact - Custom AzureResponsesVersion: properly respected for compact too Co-authored-by: 彭俊杰 <pengjunjie@onero.com>
…uantumNous#4149) The Azure channel's GetRequestURL method only handled RelayModeResponses but missed RelayModeResponsesCompact. This caused compact requests to fall through to the generic deployments URL pattern, producing an incorrect path that Azure returns 404 for. This fix extends the existing responses API special handling to also cover the compact mode, appending /compact to the subUrl when the relay mode is ResponsesCompact. Affected URLs (before → after): - Normal Azure: /openai/deployments/{model}/responses/compact → /openai/v1/responses/compact - cognitiveservices: same pattern → /openai/responses/compact - Custom AzureResponsesVersion: properly respected for compact too Co-authored-by: 彭俊杰 <pengjunjie@onero.com>
Problem
The Azure channel's
GetRequestURLmethod inrelay/channel/openai/adaptor.goonly handlesRelayModeResponsesbut missesRelayModeResponsesCompact. When Codex CLI/IDE triggers context compaction viaPOST /v1/responses/compact, requests routed through an Azure channel fall through to the generic deployments URL pattern, producing:Azure doesn't recognize this path and returns 404.
Fix
Extend the existing
RelayModeResponsescondition (line 139) to also matchRelayModeResponsesCompact, and append/compacttosubUrlwhen in compact mode.URL comparison (before → after)
/openai/deployments/{model}/responses/compact?api-version=xxx/openai/v1/responses/compact?api-version=preview/openai/responses/compact?api-version={apiVersion}Changes
relay/channel/openai/adaptor.go: 7 lines changed (2 modified + 5 added)Testing
/v1/responsesrouting remains unchangedDoResponse, line 634) already has theRelayModeResponsesCompactcase, so only the URL routing was missingSummary by CodeRabbit
New Features