github / github/copilot-cli

BYOK Azure: `wire_api: completions` ignored; hardcoded api-version rejected by Azure OpenAI Responses API

未关闭
#3,208 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
area:configuration area:models
主要语言
Shell
星标
11.2k
派生
1.9k
平均合并
14 小时 16 分钟
30 天内合并 PR
6

描述

### Summary

When the GitHub Copilot CLI is configured (via `github-copilot-sdk`'s
`ProviderConfig`) to use `type: azure` with `wire_api: completions`,
the CLI ignores `wire_api` and sends requests to Azure OpenAI's
**Responses API** endpoint (`/openai/responses`) anyway. It also
appears to use a hardcoded api-version (per `copilot/session.py:819`
SDK docstring, defaults to `2024-10-21`) regardless of what's passed
in `azure.api_version`, which Azure OpenAI rejects for the Responses
API path:

```
400 Azure OpenAI Responses API is enabled only for api-version
2025-03-01-preview and later
```

This makes BYOK against Azure OpenAI / Microsoft Foundry deployments
non-functional today.

### Environment

- `copilot` CLI: `0.0.353` (Commit `f8fd3e3`), installed via Homebrew
- `github-copilot-sdk`: `0.3.0` (Python wrapper)
- Host: macOS 25.4.0 / arm64
- Upstream: Azure OpenAI deployment provisioned through Microsoft
Foundry hub (endpoint `https://.openai.azure.com`)
- Auth: Azure AD bearer token via `az account get-access-token
--resource https://cognitiveservices.azure.com`

### Reproducer

```python
import asyncio
from copilot import CopilotClient, ProviderConfig

async def main() -> None:
client = CopilotClient()
provider = ProviderConfig(
type="azure",
wire_api="completions", # asks for Chat Completions
base_url="https://.openai.azure.com",
bearer_token="",
azure={"api_version": "2025-04-01-preview"}, # explicit modern version
)
session = await client.create_session(
model="gpt-5",
working_directory="/tmp/test",
provider=provider,
on_permission_request=lambda *a, **kw: {"behavior": "allow"},
)
response = await session.send_and_wait("Write hello.py")
print(response)

asyncio.run(main())
```

### Expected behavior

The Copilot CLI sends requests to
`/openai/v1/chat/completions` (Chat Completions endpoint,
no api-version constraint), OR honors the explicit
`azure.api_version` passed in the ProviderConfig.

### Actual behavior

`~/.copilot/logs/process-*.log` shows:

```
[INFO] Using custom provider: type=azure, baseUrl=,
wireApi=responses ← wire_api was set to "completions"
[ERROR] {
"code": "BadRequest",
"message": "Azure OpenAI Responses API is enabled only for
api-version 2025-03-01-preview and later"
}
```

Two distinct issues:

1. **`wire_api: completions` is ignored** — log line shows
`wireApi=responses` even when SDK input was
`wire_api="completions"`.
2. **`azure.api_version` is ignored or overridden** — the request
that reaches Azure OpenAI uses a version older than
`2025-03-01-preview` despite us setting
`azure.api_version="2025-04-01-preview"` in `ProviderConfig`.

The same error reproduces with `wire_api: responses`, `model:
gpt-5.4`, and explicit `azure.api_version` overrides up to
`2026-01-01-preview`.

### Suggested fixes (any one would unblock BYOK Azure paths)

1. **Honor `wire_api: completions` for `type: azure`** — route to
`/openai/v1/chat/completions` instead of
`/openai/responses` when set. (Cleanest; matches the SDK
schema's `wire_api: Literal['completions', 'responses']` typing.)
2. **Honor `azure.api_version`** — pass through to the request URL
query string (`?api-version=...`) so operators can opt into
newer Azure API surfaces.
3. **Bump the hardcoded default to `2025-03-01-preview`** — at
minimum bring the default in line with current Azure OpenAI
Responses API requirements.

---

---
**Possibly related (different concrete symptoms, same general area):**
- #2576 — BYOK azure provider 404 error
- #2710 — Proposal: External model provider API surface for Copilot CLI
- #2755 — CLI headless mode: latency degradation under BYOK

贡献指南

打开贡献指南

调研方向

Reproduce the Azure provider configuration and inspect copilot/session.py:819 alongside the ProviderConfig handling for wire_api and azure.api_version. Compare the request endpoint, wireApi log value, and API-version sent with the expected configuration. Done means completions routes to /openai/v1/chat/completions or the explicit Azure API version is honored, avoiding the reported rejection.

由索引模型根据 Issue 内容生成。

评估

技术栈
azure, python
领域
api, backend, cloud
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。