Skip to content

fix: add Azure channel support for /v1/responses/compact URL routing - #4149

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
woan-pengjunjie:fix/azure-responses-compact-url
Apr 13, 2026
Merged

fix: add Azure channel support for /v1/responses/compact URL routing#4149
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
woan-pengjunjie:fix/azure-responses-compact-url

Conversation

@woan1136

@woan1136 woan1136 commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Problem

The Azure channel's GetRequestURL method in relay/channel/openai/adaptor.go only handles RelayModeResponses but misses RelayModeResponsesCompact. When Codex CLI/IDE triggers context compaction via POST /v1/responses/compact, requests routed through an Azure channel fall through to the generic deployments URL pattern, producing:

/openai/deployments/{model}/responses/compact?api-version=xxx

Azure doesn't recognize this path and returns 404.

Fix

Extend the existing RelayModeResponses condition (line 139) to also match RelayModeResponsesCompact, and append /compact to subUrl when in compact mode.

URL comparison (before → after)

Scenario Before (broken) After (fixed)
Normal Azure /openai/deployments/{model}/responses/compact?api-version=xxx /openai/v1/responses/compact?api-version=preview
cognitiveservices.azure.com same broken pattern /openai/responses/compact?api-version={apiVersion}
Custom AzureResponsesVersion ignored for compact properly respected

Changes

  • relay/channel/openai/adaptor.go: 7 lines changed (2 modified + 5 added)

Testing

  • Verified URL generation logic for all three Azure URL variants (normal, cognitiveservices, custom version)
  • Confirmed that non-compact /v1/responses routing remains unchanged
  • Response handling side (DoResponse, line 634) already has the RelayModeResponsesCompact case, so only the URL routing was missing

Summary by CodeRabbit

New Features

  • Added Azure OpenAI compact response mode support, enabling more efficient response handling alongside standard responses.

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
Copilot AI review requested due to automatic review settings April 8, 2026 12:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 GetRequestURL responses-API special-case to include RelayModeResponsesCompact.
  • Append /compact to the Azure responses sub-path when in compact mode.
  • Preserve existing behavior for standard /v1/responses and non-responses endpoints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai

coderabbitai Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6660770f-9c22-4062-9c62-56fa535df5dc

📥 Commits

Reviewing files that changed from the base of the PR and between 78e4cb3 and 902d368.

📒 Files selected for processing (1)
  • relay/channel/openai/adaptor.go

Walkthrough

The change extends Azure OpenAI responses request URL construction to handle a new relay mode (RelayModeResponsesCompact) by appending a /compact subpath to the responses endpoint while maintaining existing API version selection logic.

Changes

Cohort / File(s) Summary
Azure OpenAI Responses URL Handling
relay/channel/openai/adaptor.go
Added conditional logic to append /compact subpath to responses endpoint URL for RelayModeResponsesCompact mode, separate from standard RelayModeResponses handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A compact twist, a path so neat,
/compact appended, the change complete,
Azure URLs now know the way,
To serve responses, compact today! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: adding Azure channel support for /v1/responses/compact URL routing, which is the core change in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@seefs001

seefs001 commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator

有Azure支持的文档地址吗?这个compact之前Azure是不支持的

@woan1136

woan1136 commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

有Azure支持的文档地址吗?这个compact之前Azure是不支持的

这是 Azure 官方文档中关于 Compact a response 端点的说明:

📄 Azure OpenAI Responses API - Compact a response
https://learn.microsoft.com/en-us/azure/foundry/openai/how-to/responses?tabs=rest-api#compact-a-response

以及 OpenAI 官方 API 参考文档:
https://developers.openai.com/api/reference/resources/responses/methods/compact

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 响应对象。

@Calcium-Ion
Calcium-Ion merged commit 3ab65a8 into QuantumNous:main Apr 13, 2026
4 of 5 checks passed
zjcp pushed a commit to zjcp/new-api that referenced this pull request Apr 14, 2026
…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>
nonepage referenced this pull request in nonepage/new-api Apr 14, 2026
…(#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)
piexian pushed a commit to piexian/new-api that referenced this pull request Apr 16, 2026
…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>
TonyTown6033 pushed a commit to TonyTown6033/new-api that referenced this pull request Apr 17, 2026
…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)
ntz857 pushed a commit to ntz857/new-api that referenced this pull request Apr 19, 2026
…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>
xyfacai pushed a commit to xyfacai/new-api that referenced this pull request Apr 20, 2026
…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>
rockyicer pushed a commit to rockyicer/new-api that referenced this pull request May 7, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants