Skip to content

Commit 4681e04

Browse files
lpcoxCopilot
andauthored
fix: add explicit model for Copilot BYOK smoke test (#2006)
* fix: add explicit model for Copilot BYOK mode Copilot CLI requires --model when running in BYOK/offline mode. Without it, all attempts fail with: 'BYOK providers require an explicit model.' Set COPILOT_MODEL=gpt-4.1 in workflow env and override the compiler's empty default fallback in the lock file. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: inject Copilot-Integration-Id header in api-proxy api.githubcopilot.com requires the Copilot-Integration-Id header. In BYOK mode, the Copilot CLI sends plain OpenAI-compatible requests without Copilot-specific headers. The api-proxy sidecar must inject this header when proxying to the Copilot API. Uses 'copilot-developer-cli' as the default integration ID, matching the Copilot CLI's own value. Configurable via COPILOT_INTEGRATION_ID env var. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * feat: align BYOK smoke test with copilot smoke test workload - Add GitHub.com connectivity check and pre-fetched PR data comparison - Add all 4 test sections: MCP, connectivity, file I/O, BYOK inference - Update model from gpt-4.1 to gpt-5.4 - Recompile and post-process lock file Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: switch BYOK model to gpt-5.3-codex gpt-5.4 returns 400 on tools[5].function.name empty string, likely a stricter validation in that model. Try gpt-5.3-codex. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: recompile lock file for gpt-5.3-codex model change Previous commit only patched the lock file without recompiling, causing frontmatter hash mismatch at runtime. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: switch BYOK model to claude-opus-4.6 gpt-5.3-codex is not accessible via /chat/completions endpoint. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * chore: bump Copilot CLI to 1.0.28 for BYOK testing Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 2277b4b commit 4681e04

File tree

3 files changed

+70
-22
lines changed

3 files changed

+70
-22
lines changed

.github/workflows/smoke-copilot-byok.lock.yml

Lines changed: 27 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/smoke-copilot-byok.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ safe-outputs:
3838
timeout-minutes: 5
3939
env:
4040
COPILOT_API_KEY: dummy-byok-key-for-offline-mode
41+
COPILOT_MODEL: claude-opus-4.6
4142
features:
4243
cli-proxy: true
4344
strict: true
@@ -50,6 +51,18 @@ steps:
5051
echo "COPILOT_API_TARGET=${COPILOT_API_TARGET:-api.githubcopilot.com (default)}"
5152
echo "::endgroup::"
5253
54+
echo "::group::Fetching last 2 merged PRs"
55+
PR_DATA=$(gh pr list --repo "$GITHUB_REPOSITORY" --state merged --limit 2 \
56+
--json number,title,author,mergedAt \
57+
--jq '.[] | "PR #\(.number): \(.title) (by @\(.author.login), merged \(.mergedAt))"')
58+
echo "$PR_DATA"
59+
echo "::endgroup::"
60+
61+
echo "::group::GitHub.com connectivity check"
62+
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 10 https://github.com)
63+
echo "github.com returned HTTP $HTTP_CODE"
64+
echo "::endgroup::"
65+
5366
echo "::group::File write/read test"
5467
TEST_DIR="/tmp/gh-aw/agent"
5568
TEST_FILE="$TEST_DIR/smoke-test-copilot-byok-${GITHUB_RUN_ID}.txt"
@@ -60,9 +73,15 @@ steps:
6073
echo "::endgroup::"
6174
6275
{
76+
echo "SMOKE_PR_DATA<<SMOKE_EOF"
77+
echo "$PR_DATA"
78+
echo "SMOKE_EOF"
79+
echo "SMOKE_HTTP_CODE=$HTTP_CODE"
6380
echo "SMOKE_FILE_CONTENT=$FILE_CONTENT"
6481
echo "SMOKE_FILE_PATH=$TEST_FILE"
6582
} >> "$GITHUB_OUTPUT"
83+
env:
84+
GH_TOKEN: ${{ github.token }}
6685
post-steps:
6786
- name: Validate safe outputs were invoked
6887
run: |
@@ -105,21 +124,34 @@ This smoke test validates that Copilot CLI runs in **offline BYOK mode** — wit
105124

106125
## Pre-Computed Test Results
107126

108-
### 1. File Write/Read Test
127+
The following tests were already executed in a deterministic pre-agent step. Your job is to verify the results and produce the summary comment.
128+
129+
### 1. GitHub MCP Testing
130+
Verify MCP connectivity by calling `github-list_pull_requests` for ${{ github.repository }} (limit 1, state merged). Confirm the result matches the pre-fetched data below.
131+
132+
### 2. GitHub.com Connectivity
133+
Pre-step result: HTTP ${{ steps.smoke-data.outputs.SMOKE_HTTP_CODE }} from github.com.
134+
✅ if HTTP 200 or 301, ❌ otherwise.
135+
136+
### 3. File Write/Read Test
109137
Pre-step wrote and read back: "${{ steps.smoke-data.outputs.SMOKE_FILE_CONTENT }}"
110138
File path: ${{ steps.smoke-data.outputs.SMOKE_FILE_PATH }}
111139
Verify by running `cat` on the file path using bash to confirm it exists.
112140

113-
### 2. GitHub MCP Testing
114-
Verify MCP connectivity by calling `github-list_pull_requests` for ${{ github.repository }} (limit 1, state merged). Confirm the result returns data.
115-
116-
### 3. BYOK Inference Test
141+
### 4. BYOK Inference Test
117142
You are running in offline BYOK mode right now. The fact that you can read this prompt and respond means the BYOK inference path (agent → api-proxy sidecar → api.githubcopilot.com) is working. Confirm ✅.
118143

144+
## Pre-Fetched PR Data
145+
146+
```
147+
${{ steps.smoke-data.outputs.SMOKE_PR_DATA }}
148+
```
149+
119150
## Output
120151

121152
Add a **very brief** comment (max 5-10 lines) to the current pull request with:
122-
- ✅ or ❌ for each test result (file I/O, MCP, inference)
153+
- PR titles only (no descriptions)
154+
- ✅ or ❌ for each test result
123155
- Note: "Running in BYOK offline mode (COPILOT_OFFLINE=true) via api-proxy → api.githubcopilot.com"
124156
- Overall status: PASS or FAIL
125157
- Mention the pull request author and any assignees

containers/api-proxy/server.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function resolveCopilotAuthToken(env = process.env) {
7878
}
7979

8080
const COPILOT_AUTH_TOKEN = resolveCopilotAuthToken(process.env);
81+
const COPILOT_INTEGRATION_ID = process.env.COPILOT_INTEGRATION_ID || 'copilot-developer-cli';
8182
const GEMINI_API_KEY = (process.env.GEMINI_API_KEY || '').trim() || undefined;
8283

8384
/**
@@ -337,7 +338,7 @@ function resolveOpenCodeRoute(openaiKey, anthropicKey, copilotToken, openaiTarge
337338
return { target: anthropicTarget, headers: { 'x-api-key': anthropicKey }, basePath: anthropicBasePath, needsAnthropicVersion: true };
338339
}
339340
if (copilotToken) {
340-
return { target: copilotTarget, headers: { 'Authorization': `Bearer ${copilotToken}` }, basePath: undefined, needsAnthropicVersion: false };
341+
return { target: copilotTarget, headers: { 'Authorization': `Bearer ${copilotToken}`, 'Copilot-Integration-Id': COPILOT_INTEGRATION_ID }, basePath: undefined, needsAnthropicVersion: false };
341342
}
342343
return null;
343344
}
@@ -1012,18 +1013,21 @@ if (require.main === module) {
10121013
if (isModelsPath && req.method === 'GET' && COPILOT_GITHUB_TOKEN) {
10131014
proxyRequest(req, res, COPILOT_API_TARGET, {
10141015
'Authorization': `Bearer ${COPILOT_GITHUB_TOKEN}`,
1016+
'Copilot-Integration-Id': COPILOT_INTEGRATION_ID,
10151017
}, 'copilot');
10161018
return;
10171019
}
10181020

10191021
proxyRequest(req, res, COPILOT_API_TARGET, {
10201022
'Authorization': `Bearer ${COPILOT_AUTH_TOKEN}`,
1023+
'Copilot-Integration-Id': COPILOT_INTEGRATION_ID,
10211024
}, 'copilot');
10221025
});
10231026

10241027
copilotServer.on('upgrade', (req, socket, head) => {
10251028
proxyWebSocket(req, socket, head, COPILOT_API_TARGET, {
10261029
'Authorization': `Bearer ${COPILOT_AUTH_TOKEN}`,
1030+
'Copilot-Integration-Id': COPILOT_INTEGRATION_ID,
10271031
}, 'copilot');
10281032
});
10291033

0 commit comments

Comments
 (0)