Skip to content

Honor wire API overrides in Copilot SDK provider resolution - #64969

Merged
pelikhan merged 9 commits into
mainfrom
copilot/gpt-6-luna-fail-copilot-sdk
Oct 2, 2026
Merged

pelikhan merged 9 commits into
mainfrom
copilot/gpt-6-luna-fail-copilot-sdk

Conversation

Copilot AI commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Copilot SDK multi-provider resolution ignored COPILOT_PROVIDER_WIRE_API, routing gpt-6-luna through /chat/completions when catalog inference fell back to completions despite an explicit Responses API setting.

  • Routing: Forward the configured wire API into reflection resolution and apply valid overrides only to the selected primary provider.
  • Compatibility: Preserve Anthropic behavior, other providers’ inferred APIs, and task-level routing precedence.
  • Regression coverage: Cover missing/stale catalogs, Responses and Completions overrides, multi-provider selection, and fallback models.

The following setting now propagates to both SDK provider configuration and the sidecar environment:

engine:
  id: copilot
  copilot-sdk: true
  model: gpt-6-luna
  env:
    COPILOT_PROVIDER_WIRE_API: responses

Copilot AI changed the title [WIP] Fix gpt-6-luna routing issue with Copilot SDK Honor wire API overrides in Copilot SDK provider resolution Oct 2, 2026
Copilot AI requested a review from pelikhan October 2, 2026 08:23
@igolaizola

Copy link
Copy Markdown

I've seen that the AI is taking the approach of fixing this by correctly honoring COPILOT_PROVIDER_WIRE_API: responses. However, it would also be nice if gpt-6-luna worked out of the box, without requiring specifying the COPILOT_PROVIDER_WIRE_API env var.

/cc @copilot @pelikhan

@pelikhan
pelikhan marked this pull request as ready for review October 2, 2026 13:30
Copilot AI balanced review requested due to automatic review settings October 2, 2026 13:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Automatically inferred Copilot settings can override another provider’s catalog and select an unsupported API.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates gh-aw’s Copilot SDK provider resolution to honor explicit wire API settings, addressing #64965.

Changes:

  • Forwards wire API settings and applies valid overrides to the primary non-Anthropic provider.
  • Adds regression coverage for catalogs, provider selection, overrides, and fallback models.
  • Refreshes generated workflow dependencies and action pins.
File Description
actions/​setup/​js/​copilot_harness.cjs Forwards the wire API setting into SDK resolution.
actions/​setup/​js/​awf_reflect.test.cjs Adds wire API override regression cases.
actions/​setup/​js/​awf_reflect.cjs Applies primary-provider overrides.
.github/​workflows/​visual-regression-checker.lock.yml Updates container pins and network allowlist.
.github/​workflows/​spec-enforcer.lock.yml Updates the coverage upload action.
.github/​workflows/​purelock.lock.yml Updates the coverage upload action.
.github/​aw/​actions-lock.json Downgrades stale-repos and super-linter pins.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

const modelsJson = loadModelsJson();

const multiProvider = resolveMultiProviderFromReflect({ model: configuredModel, reflectData: awfReflectData, modelsJson, logger: log });
const multiProvider = resolveMultiProviderFromReflect({ model: configuredModel, wireApi: process.env.COPILOT_PROVIDER_WIRE_API, reflectData: awfReflectData, modelsJson, logger: log });

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.

Guarded applyCopilotWireAPI() with !copilotSDKMode so SDK provider resolution retains each provider’s inferred API while still receiving explicit overrides and task-routing selections. Committed as 9f39855.

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.

SDK mode now skips applyCopilotWireAPI; provider wire APIs remain catalog-inferred unless an explicit override or task-routing selection is supplied. Added GPT-5+ Responses defaults and regression coverage in 9906620.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick triage nudge: branch refresh was attempted by sous-chef. Please review the current state of this PR and run the pr-finisher skill to move it toward merge readiness.

Generated by 👨🍳 PR Sous Chef

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 23.2 AIC · ⌖ 8.74 AIC · ⊞ 9.7K · ◷
Comment /souschef to run again

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

No ADR enforcement needed: PR does not have the 'implementation' label and has <=100 new lines of code in business logic directories.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Generated by Ponytail Reviewer for #64969

Co-authored-by: gh-aw-bot <[email protected]>
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-10-02T13:57:00Z
review_event: REQUEST_CHANGES
top_themes:
  - wire-api override precedence conflates explicit overrides with auto-configured values
files_reviewed:
  - .github/aw/actions-lock.json
  - .github/workflows/purelock.lock.yml
  - .github/workflows/spec-enforcer.lock.yml
  - .github/workflows/visual-regression-checker.lock.yml
  - actions/setup/js/awf_reflect.cjs
  - actions/setup/js/awf_reflect.test.cjs
  - actions/setup/js/copilot_harness.cjs
comment_count: 0

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

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 30.6 AIC · ⌖ 7.39 AIC · ⊞ 20.2K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Request changes

The new wire-API precedence still conflates an explicit override with the auto-configured COPILOT_PROVIDER_WIRE_API, so SDK mode can silently rewrite the fallback provider to the wrong protocol.

Why this blocks merge

applyCopilotWireAPI() runs before resolveMultiProviderFromReflect() and eagerly populates process.env.COPILOT_PROVIDER_WIRE_API from the catalog or the GPT fallback. This patch then unconditionally forwards that env var as options.wireApi, so any time the configured model is missing from reflect data and resolution falls back to the first available model/provider, the fallback provider inherits the configured model’s wire API instead of its own inferred protocol. A concrete failure mode is COPILOT_MODEL=gpt-6-luna with no explicit override, reflect only exposing a completions-only fallback model, and the fallback endpoint being forced onto responses.

The override needs to be limited to values that actually came from an explicit user/workflow setting, or the fallback path needs to recompute against the resolved primary model instead of trusting the pre-populated env var.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 30.6 AIC · ⌖ 7.39 AIC · ⊞ 20.2K
Comment /review to run again

@pelikhan

pelikhan commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

@copilot update the models.json with wire information for got 6 models.

See #64969 (comment)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Applied harden + audit Impeccable modes (bug-fix change type) to this error-routing/edge-case patch.

Blocking: The wire-API override forwards the auto-populated COPILOT_PROVIDER_WIRE_API env var (set by applyCopilotWireAPI() for the originally-configured model) without distinguishing it from an explicit user/workflow setting. When model resolution falls back to a different primary model/provider, this stale override is still applied, silently routing the fallback provider through the wrong wire API. Reproduced locally — see inline comment.

Non-blocking: .github/aw/actions-lock.json downgrades two pinned actions (stale-repos v9.0.19→v9.0.18, super-linter v9.0.0→v8.7.0), unrelated to the stated fix; likely a regeneration artifact worth double-checking.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · copilot · sonnet50 · 59.7 AIC · ⌖ 13.3 AIC · ⊞ 8.1K

const primaryProviderName = models.find(m => m.id === primaryModel)?.provider;
const primaryProvider = providers.find(p => p.name === primaryProviderName);
const wireApi = options?.wireApi;
if (primaryProvider && primaryProvider.type !== "anthropic" && (wireApi === "responses" || wireApi === "completions")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

options.wireApi is forwarded straight from process.env.COPILOT_PROVIDER_WIRE_API, which by this point may have been auto-populated by applyCopilotWireAPI() for the originally-configured model (catalog lookup or the GPT-prefix heuristic), not necessarily an explicit user/workflow override.

When resolveMultiProviderFromReflect falls back to a different primary model (e.g. the configured model isn't present in reflect data), this auto-inferred wire API — computed for a model that is no longer the one actually selected — gets applied to the fallback provider anyway, silently overriding its correctly-inferred wire API.

Repro: COPILOT_MODEL=gpt-6-luna (not in reflect data) → applyCopilotWireAPI() sets COPILOT_PROVIDER_WIRE_API=responses via the GPT heuristic → resolveMultiProviderFromReflect falls back to a completions-only model from reflect data → that model's provider incorrectly gets wireApi: "responses".

$ node repro.cjs
{
  "model": "some-completions-only-model",
  "providers": [{ "name": "copilot", "type": "openai", "baseUrl": "...", "wireApi": "responses" }]
}

Expected wireApi: "completions" (as correctly inferred from the catalog), but the auto-populated override wins.

Suggest either: (1) only apply the override when primaryModel === configuredModel (i.e., the override's intended model was actually selected), or (2) have the caller pass a flag distinguishing an explicit user override from an auto-populated default, and only forward the explicit case.

@copilot please address this.

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.

applyCopilotWireAPI() is now skipped in SDK mode, so the reflection resolver only receives a caller-provided override and otherwise keeps its per-provider catalog inference. This is covered by commit 9f39855.

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.

Automatic wire API inference is now excluded from SDK-mode overrides; SDK providers infer from their selected models, including fallback models. Explicit environment overrides and task routing remain honored. Fixed in 9906620.

"sha": "c42a2821e3ef0cee1b1bc20b7eecbb2bfa7a83b4"
},
"haskell-actions/[email protected]": {
"repo": "haskell-actions/setup",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This downgrades pinned actions: github/stale-repos v9.0.19 → v9.0.18 and super-linter/super-linter v9.0.0 → v8.7.0. These version/SHA changes appear unrelated to the wire-API fix in this PR and look like an unintended side effect of a regeneration step picking up a stale lock source. If intentional (e.g. reverting a problematic upgrade), please note the reason in the PR description; otherwise this should be reverted to avoid silently rolling back security/feature updates to these actions.

@copilot please address this.

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.

Restored the v9.0.19 and v9.0.0 action-pin entries and their mirrored catalogs to the PR-base state in 2c45607; the downgrade is no longer part of the PR diff.

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.

Restored the newer action pins and synchronized the generated pin data/lock files in 2c45607 and 9906620.

@pelikhan

pelikhan commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

@copilot Recent OpenAI models have switched to responses so this should be the default for know oai models.

  • update model list with wire info
  • add simple heuristic for gpt* models

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /diagnosing-bugs — the regression test suite for resolveMultiProviderFromReflect is thorough (missing/stale catalog, multi-provider isolation, Anthropic exclusion, invalid values), but the integration between applyCopilotWireAPI() and the new wireApi forwarding has a real correctness gap: requesting changes.

📋 Key Themes & Highlights

Key Themes

  • Ordering bug: copilot_harness.cjs reads process.env.COPILOT_PROVIDER_WIRE_API for the new wireApi option after applyCopilotWireAPI() may have auto-set it from catalog/GPT-prefix inference. That conflates "user override" with "auto-inferred default", undermining the PR's own stated goal of honoring explicit overrides over catalog inference — the fallback inference can now win via a different code path. No existing test (in either awf_reflect.test.cjs or copilot_harness.test.cjs) exercises this interaction end-to-end, so it isn't caught today.
  • Case sensitivity: the new override check in resolveMultiProviderFromReflect (wireApi === "responses" || wireApi === "completions") is strict-equality on a raw env string, unlike inferWireApiForModel's normalized lowercase/trim comparison. A value like Responses silently falls back to catalog inference instead of applying (or rejecting) the override.

Positive Highlights

  • ✅ Good regression coverage for the primary scenario (stale/missing catalog + Responses override) and multi-provider isolation (override applies only to the selected provider, not siblings).
  • ✅ Correctly excludes Anthropic providers from the override, matching the existing "Anthropic has no OpenAI wire API" invariant.
  • ✅ JSDoc update clearly documents the new wireApi semantics.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 111.5 AIC · ⌖ 14.7 AIC · ⊞ 10K
Comment /matt to run again

const primaryProviderName = models.find(m => m.id === primaryModel)?.provider;
const primaryProvider = providers.find(p => p.name === primaryProviderName);
const wireApi = options?.wireApi;
if (primaryProvider && primaryProvider.type !== "anthropic" && (wireApi === "responses" || wireApi === "completions")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/diagnosing-bugs] The override check wireApi === "responses" || wireApi === "completions" is case-/whitespace-sensitive, but wireApi flows straight from process.env.COPILOT_PROVIDER_WIRE_API (a user-authored YAML string in engine.env). A value like Responses or " responses " silently falls through to catalog inference instead of applying the explicit override or erroring — exactly the kind of footgun this PR is fixing for the model-name case, just reintroduced for the wireApi value itself.

💡 Suggested fix + missing test

Normalize the same way inferWireApiForModel already does for catalog entries:

const wireApi = String(options?.wireApi || "").toLowerCase().trim();
if (primaryProvider && primaryProvider.type !== "anthropic" && (wireApi === "responses" || wireApi === "completions")) {
  primaryProvider.wireApi = wireApi;
  ...
}

The new test suite (it.each(["", "grpc", undefined])) covers invalid/absent values but doesn't exercise mixed-case or padded input, so this regression wouldn't be caught today. Add a case like wireApi: "Responses" asserting the override still applies.

@copilot please address this.

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.

Normalized configured wire API values with lowercase/trim and added mixed-case and whitespace regression cases in 2c45607.

const modelsJson = loadModelsJson();

const multiProvider = resolveMultiProviderFromReflect({ model: configuredModel, reflectData: awfReflectData, modelsJson, logger: log });
const multiProvider = resolveMultiProviderFromReflect({ model: configuredModel, wireApi: process.env.COPILOT_PROVIDER_WIRE_API, reflectData: awfReflectData, modelsJson, logger: log });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/diagnosing-bugs] process.env.COPILOT_PROVIDER_WIRE_API is read here after applyCopilotWireAPI() ran at line 1261 and may have auto-set it (e.g. defaulting any unrecognized GPT-prefixed model to responses). That means resolveMultiProviderFromReflect can receive an auto-inferred default disguised as an explicit override, overriding its own per-provider catalog inference and silently flipping the wrong model's wire API.

💡 Suggested fix

Snapshot the env value before applyCopilotWireAPI() runs, so only a genuine user-set engine.env.COPILOT_PROVIDER_WIRE_API is forwarded as an override:

const explicitWireApi = process.env.COPILOT_PROVIDER_WIRE_API; // capture before applyCopilotWireAPI may auto-set it
// ...
applyCopilotWireAPI({ modelsJson: loadModelsJson(), logger: log });
// ...
const multiProvider = resolveMultiProviderFromReflect({ model: configuredModel, wireApi: explicitWireApi, reflectData: awfReflectData, modelsJson, logger: log });

No existing test in copilot_harness.test.cjs exercises resolveMultiProviderFromReflect's wireApi forwarding together with applyCopilotWireAPI's auto-default, so this gap isn't currently caught.

@copilot please address this.

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.

applyCopilotWireAPI() is skipped in SDK mode in 9f39855, so inferred defaults are not forwarded as user overrides; task-level routing still takes precedence.

Copilot AI requested a review from gh-aw-bot October 2, 2026 14:21

Copilot AI commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot Quick triage nudge: branch refresh was attempted by sous-chef. Please review the current state of this PR and run the pr-finisher skill to move it toward merge readiness.

Generated by [�...

Reviewed the PR, applied the model-catalog and review fixes, and completed local validation in 9906620. CI on this updated HEAD still needs a maintainer-triggered run.

@copilot Recent OpenAI models have switched to responses so this should be the default for know oai models.

  • update model list with wire info...

Added catalog Responses metadata for known GPT-5+ models and a GPT-5+ fallback heuristic, while preserving GPT-4 completions inference and explicit overrides. Implemented in 9906620.

@copilot update the models.json with wire information for got 6 models.

See #64969 (comment)

Added Responses metadata for known GPT-5+ models in both synchronized catalogs and the GPT-5+ fallback heuristic; GPT-6 works without an environment override. See 9906620.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please review this PR and run the pr-finisher skill to move it forward.

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 6.31 AIC · ⌖ 8.51 AIC · ⊞ 9.2K · ◷
Comment /souschef to run again

Copilot AI commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please review this PR and run the pr-finisher skill to move it forward.

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 �...

Restored the newer action pins and pushed be703c5. make fmt, make lint, recompile, and the targeted provider regression tests (422 tests) passed. The Go integration suite currently fails on unrelated version-constant assertions; I also found unresolved review threads, and the available tools here do not expose thread resolution.

@pelikhan
pelikhan merged commit 70674c1 into main Oct 2, 2026
1 check passed
@pelikhan
pelikhan deleted the copilot/gpt-6-luna-fail-copilot-sdk branch October 2, 2026 14:58
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.90.3

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.

gpt-6-luna fails with Copilot SDK because it is routed through /chat/completions

5 participants