Skip to content

auto-configure COPILOT_PROVIDER_WIRE_API from model catalog#46156

Open
pelikhan with Copilot wants to merge 9 commits into
mainfrom
copilot/update-generated-code-config
Open

auto-configure COPILOT_PROVIDER_WIRE_API from model catalog#46156
pelikhan with Copilot wants to merge 9 commits into
mainfrom
copilot/update-generated-code-config

Conversation

Copilot AI commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Models like gpt-5-mini, gpt-5.x, and mai-code-1-flash-picker require the OpenAI Responses API (wire_api: responses); the Copilot CLI defaults to completions, causing HTTP 400 failures. Since the model may be resolved from a GitHub org variable at runtime, wire API selection must happen before Copilot CLI launches.

Changes

  • pkg/workflow/data/wire_api_models.json — embedded catalog of wire_api values for github-copilot provider models, extracted from pkg/cli/data/models.json

  • pkg/workflow/copilot_wire_api.go — model→wire_api lookup + buildCopilotWireAPIResolutionScript() that generates a shell case statement for runtime resolution

  • copilot_engine_execution.go:

    • addCopilotModelEnv: auto-sets COPILOT_PROVIDER_WIRE_API=responses in the env block for statically-configured models with wire_api: responses; user engine.env overrides win (applied after)
    • buildCopilotAWFPathSetup / buildCopilotDirectCommand: injects a shell fragment so runtime-resolved models (org variable) also get the correct wire API before Copilot starts
  • smoke-copilot-mai.md: removes manual COPILOT_PROVIDER_WIRE_API: responses — now auto-configured

Runtime resolution (dynamic model case)

if [ -z "${COPILOT_PROVIDER_WIRE_API:-}" ]; then
  case "${COPILOT_MODEL:-}" in
    gpt-5-mini|gpt-5.2|...|mai-code-1-flash-picker)
      export COPILOT_PROVIDER_WIRE_API=responses
      ;;
    gemini-2.5-pro|...|raptor-mini)
      export COPILOT_PROVIDER_WIRE_API=completions
      ;;
  esac
fi

The [ -z "${COPILOT_PROVIDER_WIRE_API:-}" ] guard ensures explicit engine.env values always take precedence. Unknown models (e.g. BYOK custom deployments) are left unset, requiring manual configuration as before.

- Add pkg/workflow/data/wire_api_models.json with github-copilot model
  wire_api mappings (responses/completions), derived from pkg/cli/data/models.json
- Add pkg/workflow/copilot_wire_api.go: lookup function + shell case-statement
  generator for runtime resolution before Copilot CLI launches
- Update addCopilotModelEnv: auto-set COPILOT_PROVIDER_WIRE_API=responses in
  the env block when a static model has wire_api=responses in the catalog
- Update buildCopilotAWFPathSetup + buildCopilotDirectCommand: inject the
  wire_api case-statement into PathSetup so the dynamic (org-variable) model
  case is also handled at runtime before copilot starts
- Remove manual COPILOT_PROVIDER_WIRE_API: responses from smoke-copilot-mai.md
  since mai-code-1-flash-picker is now auto-configured
- Update golden files and recompile all 258 workflow lock files

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

Copy link
Copy Markdown
Collaborator

@copilot configuration should part of the copilot harness in JavaScript

Copilot AI and others added 2 commits July 17, 2026 06:54
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Field Value
Category feature
Risk medium
Score 42/100 (impact:20, urgency:10, quality:12)
Action defer

Rationale: DRAFT — auto-configure COPILOT_PROVIDER_WIRE_API from model catalog. Valuable fix for newer model wire API selection (HTTP 400 on gpt-5-mini etc.) but no CI yet. Defer until undrafted.

Generated by 🔧 PR Triage Agent · 166.4 AIC · ⌖ 6.15 AIC · ⊞ 5.6K ·

Copilot AI commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot configuration should part of the copilot harness in JavaScript

Done in commit c17bd06. The wire API auto-configuration is now in copilot_harness.cjs via a new applyCopilotWireAPI() function that reads wire_api from the existing models.json catalog (already contains wire_api entries for all github-copilot provider models). It runs after applyCopilotModelAliasResolution() and respects user-explicit COPILOT_PROVIDER_WIRE_API values. The Go files (copilot_wire_api.go, wire_api_models.json) and the shell-script injection in copilot_engine_execution.go have been removed.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot merge main and recompile

@pelikhan

Copy link
Copy Markdown
Collaborator

/smoke-copilot-mai

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot MAI completed successfully!

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

The threat detection results could not be parsed.

Review the workflow run logs for details.

Copilot AI and others added 2 commits July 17, 2026 07:27
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ted-code-config

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

This comment has been minimized.

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

Copilot AI commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot merge main and recompile

Done in the latest commit — merged main and recompiled all 258 workflows (0 errors).

@pelikhan

Copy link
Copy Markdown
Collaborator

Copilot AI and others added 2 commits July 17, 2026 08:55
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…jobs

Root cause: GH_AW_MODELS_JSON_PATH is exported in the path setup script pointing
to /tmp/gh-aw/models.json (the merged activation-artifact catalog). Detection and
evals jobs don't download the activation artifact, so that file doesn't exist.
loadModelsJson() used the override path, got ENOENT, returned null, and
applyCopilotWireAPI silently returned without setting COPILOT_PROVIDER_WIRE_API.

Fix: extract parseModelsJsonFile() helper and have loadModelsJson() fall back to
DEFAULT_MODELS_PATH (bundled models.json deployed alongside the module) when
GH_AW_MODELS_JSON_PATH is set but the file doesn't exist. The merged catalog is a
superset of the bundled one, so wire_api entries are always present in the fallback.

Also log when COPILOT_PROVIDER_WIRE_API is already set in applyCopilotWireAPI to
make future ambient-override issues diagnosable from CI logs.

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

Copilot AI commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot apply fix to detection and evals jobs

See https://github.com/github/gh-aw/actions/runs/29562782974/job/87829368417#step:17:1

Fixed in the latest commit.

Root cause: GH_AW_MODELS_JSON_PATH is exported in the path setup script pointing to /tmp/gh-aw/models.json (the merged catalog from the activation artifact). Detection and evals jobs don't download the activation artifact, so that file doesn't exist. loadModelsJson() used the override path, got ENOENT, returned null, and applyCopilotWireAPI silently returned without setting COPILOT_PROVIDER_WIRE_API=responses.

Fix (model_costs.cjs): extracted parseModelsJsonFile() helper and loadModelsJson() now falls back to the bundled models.json (always present alongside the module at ${RUNNER_TEMP}/gh-aw/actions/) when GH_AW_MODELS_JSON_PATH is set but the file doesn't exist. The merged catalog is a superset of the bundled one, so wire_api entries are always present in the fallback. Also added a log line in applyCopilotWireAPI when COPILOT_PROVIDER_WIRE_API is already set, to make future ambient-override issues diagnosable from CI logs.

@pelikhan

Copy link
Copy Markdown
Collaborator

/smoke-mai

@pelikhan
pelikhan marked this pull request as ready for review July 17, 2026 09:18
Copilot AI review requested due to automatic review settings July 17, 2026 09:18
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

🚀 skillet has started processing this pull request comment

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.

Pull request overview

Automatically selects the Copilot wire API from the model catalog before launch.

Changes:

  • Adds runtime wire API resolution and tests.
  • Falls back to the bundled model catalog.
  • Removes the MAI workaround and recompiles workflows.
Show a summary per file
File Description
actions/setup/js/model_costs.test.cjs Tests catalog fallback.
actions/setup/js/model_costs.cjs Adds parsing and fallback logic.
actions/setup/js/copilot_harness.test.cjs Tests wire API selection.
actions/setup/js/copilot_harness.cjs Configures the wire API before launch.
.github/workflows/smoke-copilot-mai.md Removes manual configuration.
.github/workflows/smoke-copilot-mai.lock.yml Recompiles the smoke workflow.
.github/workflows/skillet.lock.yml Refreshes generated action metadata.
.github/workflows/release.lock.yml Refreshes generated action metadata.
.github/workflows/hourly-ci-cleaner.lock.yml Refreshes generated action metadata.
.github/workflows/avenger.lock.yml Refreshes generated action metadata.

Review details

Tip

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

  • Files reviewed: 10/10 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread actions/setup/js/copilot_harness.cjs Outdated
Comment on lines +333 to +335
const normalizedModelName = modelName.toLowerCase();
for (const [key, value] of Object.entries(models)) {
if (key.toLowerCase() === normalizedModelName) {
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address the unresolved review feedback, and rerun checks once the branch is up to date.

Unresolved review threads:

Generated by PR Sous Chef: https://github.com/github/gh-aw/actions/runs/29569653113

Generated by 👨‍🍳 PR Sous Chef · 5.53 AIC · ⌖ 5.1 AIC · ⊞ 6K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address the unresolved review feedback, and rerun checks once the branch is up to date.

Unresolved review threads:...

Fixed in the latest commit. applyCopilotWireAPI now strips query parameters (e.g. gpt-5-mini?effort=highgpt-5-mini) before the catalog lookup, so effort-parameterized model names correctly resolve to their wire API. A test case for this is included.

Copilot AI requested a review from gh-aw-bot July 17, 2026 09:47
@pelikhan

Copy link
Copy Markdown
Collaborator

/smoke-copilot-mai

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot MAI completed successfully!

@github-actions

Copy link
Copy Markdown
Contributor

Recent commits focus on refactoring, linting, and threat-detection work, plus workflow/CLI and sandbox/security fixes.
There are also docs/community and release-automation updates.
Overall status: PASS

Warning

Firewall blocked 1 domain

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

  • awmgmcpg

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

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by ⚡ Smoke Copilot MAI · 3.52 AIC · ⌖ 1.42 AIC · ⊞ 14.3K ·
Comment /smoke-copilot-mai to run again
Add label smoke to run again

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.

4 participants