Skip to content

fix: resolve Copilot SDK custom provider in standalone driver main()#36769

Merged
pelikhan merged 6 commits into
mainfrom
copilot/fix-copilot-sdk-server-client-auth
Jun 4, 2026
Merged

fix: resolve Copilot SDK custom provider in standalone driver main()#36769
pelikhan merged 6 commits into
mainfrom
copilot/fix-copilot-sdk-server-client-auth

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 4, 2026

In offline+BYOK mode the AWF entrypoint unsets COPILOT_GITHUB_TOKEN, so the SDK client must authenticate via a custom provider pointing at the AWF API proxy. copilot_sdk_driver.cjs main() was calling runWithCopilotSDK with no provider, causing the SDK server to reject the session immediately:

Error: Session was not created with authentication info or custom provider

This surfaces as an unhandled Node.js promise rejection → exitCode=1, no retries.

Changes

  • awf_reflect.cjs — moves resolveCopilotSDKCustomProviderFromReflect here from copilot_harness.cjs. Requires live reflectData passed directly (no file fallback). Returns null with a log message when reflectData is not provided. fetchAWFReflect now returns the parsed reflectData in its success result. Exports both.
  • copilot_harness.cjs — fetches AWF reflect data before building the child process env, saves the live reflectData, and resolves the BYOK custom provider from it. Fails immediately (process.exit(1)) if the provider cannot be resolved — BYOK is the only supported mode and retrying a misconfigured environment is pointless. Injects GH_AW_COPILOT_SDK_PROVIDER_BASE_URL and the reflect-resolved COPILOT_MODEL into the driver subprocess environment.
  • copilot_sdk_driver.cjs — reads GH_AW_COPILOT_SDK_PROVIDER_BASE_URL from the environment injected by the harness and fails immediately if not set. Passes the resolved provider and model to runWithCopilotSDK. The silent fallback to token-based auth is removed.
  • awf_reflect.test.cjs — adds tests covering port-based URL derivation, models_url origin extraction, model endpoint selection, empty endpoint list, live reflectData parameter, and null/undefined reflectData behaviour.

The copilot_sdk_driver.cjs standalone main() was not resolving a custom
provider from the AWF reflect data before calling runWithCopilotSDK.
In offline+BYOK mode the AWF entrypoint unsets COPILOT_GITHUB_TOKEN, so
the SDK client must use a provider config pointing at the AWF API proxy
instead of token-based Copilot auth. Without a provider the SDK server
rejects the session with "Session was not created with authentication
info or custom provider", which then surfaces as an unhandled promise
rejection and a hard process exit.

Fix: move resolveCopilotSDKCustomProviderFromReflect from
copilot_harness.cjs into awf_reflect.cjs (the module that already owns
all reflect-data helpers), re-export it from copilot_harness.cjs for
backward compatibility, and call it inside copilot_sdk_driver.cjs
main() so every standalone driver run resolves and passes the provider
before creating the SDK session.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

🚀 Smoke Pi MISSION COMPLETE! Pi delivered. 🥧

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

🌑 The shadows whisper... Smoke Codex failed to deliver outputs. The oracle requires further meditation...

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

🚀 Smoke Gemini MISSION COMPLETE! Gemini has spoken. ✨

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

🚀 Smoke Antigravity MISSION COMPLETE! Antigravity has spoken. ✨

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

✅ All tools validated successfully! Agent Container Smoke Test confirms agent container is ready.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

💫 TO BE CONTINUED... Smoke Claude failed to deliver outputs! Our hero faces unexpected challenges...

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Jun 4, 2026

@copilot

  • BYOK is the only supported mode. Fail if provider is not configured.
  • use live results data from awf_reflect. No need to reload from a file, it is already available in the harness.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Agent Container Tool Check

Tool Status Version
bash 5.2.21
sh available
git 2.54.0
jq 1.7
yq 4.53.2
curl 8.5.0
gh 2.92.0
node 24.16.0
python3 3.13.13
go 1.24.13
java openjdk 21.0.11
dotnet 10.0.300

Result: 12/12 tools available ✅ — PASS

🔧 Tool validation by Agent Container Smoke Test · sonnet46 366.7K ·

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Commit pushed: 12677b5

Generated by Changeset Generator · gpt54mini 1M

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

✅ GitHub MCP Testing\n✅ Web Fetch Testing\n✅ File Writing Testing\n✅ Bash Tool Testing\n❌ Build gh-aw (Failed to download Go toolchain)\nOverall status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

Smoke Gemini — Powered by Gemini ·

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Smoke test 26922082608: FAIL

✅ Add multi-language Copilot SDK driver samples and wire daily workflows to exercise runtime installs
✅ feat: support multi-repo wildcard target-repo in safe_outputs job
❌ Serena symbol lookup
❌ web-fetch unavailable

Overall: FAIL

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex · gpt54mini 7.9M ·

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Comment Memory

Silent branch
Bootstraps the smoke run
Git and build align

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex · gpt54mini 7.9M ·

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Smoke: fix: resolve Copilot SDK custom provider in standalone driver main()
1✅ 2❌ 3✅ 4✅ 5❌ 6✅
7✅ 8✅ 9✅ 10✅ 11❌ 12✅
13✅ 14✅ 15✅ 16✅
Overall: FAIL
Author: @app/copilot-swe-agent
Assignees: @pelikhan @Copilot

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

📰 BREAKING: Report filed by Smoke Copilot · gpt54 5.1M ·

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Smoke Test: Claude — PASS (PARTIAL)

Core #1-13: ✅ all passed
PR review #14: ✅ #15: ✅ #16: ✅ #17: ⚠️ (no unresolved threads) #18: ✅ #19: ✅ #20: ⚠️ (no safe PR)
Overall: PARTIAL (only by-design skips). Run

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

💥 [THE END] — Illustrated by Smoke Claude · opus48 5.9M ·

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

💥 Automated smoke test review - all systems nominal!

Warning

Firewall blocked 6 domains

The following domains were blocked by the firewall during workflow execution:

  • accounts.google.com
  • android.clients.google.com
  • clients2.google.com
  • contentautofill.googleapis.com
  • safebrowsingohttpgateway.googleapis.com
  • www.google.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "accounts.google.com"
    - "android.clients.google.com"
    - "clients2.google.com"
    - "contentautofill.googleapis.com"
    - "safebrowsingohttpgateway.googleapis.com"
    - "www.google.com"

See Network Configuration for more information.

💥 [THE END] — Illustrated by Smoke Claude · opus48 5.9M

- fetchAWFReflect now returns reflectData in success result
- resolveCopilotSDKCustomProviderFromReflect accepts reflectData directly
  (live data from harness), falling back to file reading only when not provided
- copilot_harness.cjs: fetch reflect data before building childEnv, resolve
  BYOK provider from live data, fail fast if provider not configured,
  pass GH_AW_COPILOT_SDK_PROVIDER_BASE_URL to driver subprocess env
- copilot_sdk_driver.cjs: read GH_AW_COPILOT_SDK_PROVIDER_BASE_URL from env,
  fail immediately if not set (BYOK is the only supported mode)
- tests: add reflectData param coverage, update fetchAWFReflect result assertion

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI and others added 2 commits June 4, 2026 00:54
…l check

- resolveCopilotSDKCustomProviderFromReflect: use != null instead of 'in'
  operator so null/undefined reflectData falls back to file reading
- copilot_harness.cjs: capture resolved model from custom provider and
  inject it as COPILOT_MODEL into driver subprocess env for consistency
- tests: update reflectData:null test to reflect fallback-to-file behavior

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…solvedModel

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 4, 2026

@copilot

  • BYOK is the only supported mode. Fail if provider is not configured.
  • use live results data from awf_reflect. No need to reload from a file, it is already available in the harness.

Done in the latest commits:

  • Fail if provider not configured: copilot_harness.cjs now calls process.exit(1) immediately if resolveCopilotSDKCustomProviderFromReflect returns null in SDK mode — no retries are wasted on a misconfigured environment. copilot_sdk_driver.cjs also hard-fails if GH_AW_COPILOT_SDK_PROVIDER_BASE_URL is unset (removed the silent fallback to token-based auth).

  • Live reflect data: fetchAWFReflect now returns reflectData in its success result. The harness resolves the BYOK provider from that live object (before building childEnv) and injects GH_AW_COPILOT_SDK_PROVIDER_BASE_URL + the resolved COPILOT_MODEL into the driver subprocess environment. The driver reads both from env — no file re-read.

Comment thread actions/setup/js/awf_reflect.cjs Outdated
Comment on lines +332 to +341
// Fallback: read from the persisted reflect file.
const reflectPath = (options && options.reflectPath) || AWF_REFLECT_OUTPUT_PATH;
const readFile = (options && options.readFileSync) || fs.readFileSync;
try {
const raw = readFile(reflectPath, "utf8");
reflectData = JSON.parse(raw);
} catch (error) {
const err = /** @type {Error} */ (error);
logger(`sdk-mode: unable to read custom provider config from ${reflectPath}: ${err.message}`);
return null;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot no file fallback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed in the latest commit — resolveCopilotSDKCustomProviderFromReflect now only accepts live reflectData and returns null (with a log message) when it is not provided. The reflectPath/readFileSync parameters and the file-reading branch are gone. Tests updated accordingly.

…lect

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan June 4, 2026 01:27
@pelikhan pelikhan marked this pull request as ready for review June 4, 2026 01:29
Copilot AI review requested due to automatic review settings June 4, 2026 01:29
@pelikhan pelikhan merged commit 4757ec0 into main Jun 4, 2026
@pelikhan pelikhan deleted the copilot/fix-copilot-sdk-server-client-auth branch June 4, 2026 01:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes standalone Copilot SDK driver authentication in offline/BYOK mode by ensuring the SDK session is created with an explicit custom provider resolved from live AWF /reflect data (rather than relying on token-based auth that may be unset by the AWF entrypoint).

Changes:

  • Resolve and inject a BYOK provider base URL (and model) from live AWF reflect data in the harness, and pass it into runWithCopilotSDK.
  • Make the standalone SDK driver require GH_AW_COPILOT_SDK_PROVIDER_BASE_URL and pass a provider config to the SDK session.
  • Extend AWF reflect helpers/tests to return and consume parsed reflect payloads directly.
Show a summary per file
File Description
actions/setup/js/copilot_sdk_driver.cjs Requires an injected BYOK provider base URL and passes provider into runWithCopilotSDK.
actions/setup/js/copilot_harness.cjs Fetches live reflect data pre-run, resolves BYOK provider config, injects provider/model into driver env, and fails fast if missing.
actions/setup/js/awf_reflect.cjs Returns parsed reflectData from fetchAWFReflect and adds a live-reflect resolver for SDK custom provider config.
actions/setup/js/awf_reflect.test.cjs Adds coverage for custom-provider resolution and fetchAWFReflect returning parsed reflectData.
.changeset/patch-fix-copilot-sdk-provider.md Publishes a patch changeset describing the fix.

Copilot's findings

Tip

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

  • Files reviewed: 5/5 changed files
  • Comments generated: 3

Comment on lines +357 to +361
let model = configuredModel;
if (!model && Array.isArray(endpoint?.models)) {
const firstModel = endpoint.models.find(m => typeof m === "string" && m.trim().length > 0);
model = typeof firstModel === "string" ? firstModel.trim() : "";
}
Comment on lines +555 to 561
let awfReflectData = null;
if (process.env.AWF_REFLECT_ENABLED === "1") {
await fetchAWFReflect({ logger: log });
const reflectResult = await fetchAWFReflect({ logger: log });
if (reflectResult.ok && reflectResult.reflectData) {
awfReflectData = reflectResult.reflectData;
}
}
Comment on lines +499 to +507
const providerBaseUrl = process.env.GH_AW_COPILOT_SDK_PROVIDER_BASE_URL;
if (!providerBaseUrl) {
process.stderr.write(
"[copilot-sdk-driver] error: GH_AW_COPILOT_SDK_PROVIDER_BASE_URL is not set — " +
"BYOK provider is required; ensure the harness resolved a custom provider from awf-reflect data\n"
);
process.exit(1);
}
const provider = /** @type {import("@github/copilot-sdk").ProviderConfig} */ ({ type: "openai", baseUrl: providerBaseUrl });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants