Skip to content

Deduplicate provider adapter host/basePath/validation methods in shared adapter factory#3210

Merged
lpcox merged 3 commits into
mainfrom
copilot/fix-duplicate-provider-methods
May 15, 2026
Merged

Deduplicate provider adapter host/basePath/validation methods in shared adapter factory#3210
lpcox merged 3 commits into
mainfrom
copilot/fix-duplicate-provider-methods

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

✨ Enhancement

Four provider adapters (Anthropic, Gemini, OpenAI, Copilot) were each re-implementing the same interface surface (getTargetHost, getBasePath, and validation participation), creating avoidable duplication and drift risk. This change centralizes that shared behavior in createAdapterMethods and keeps provider-specific overrides explicit.

What does this improve?
Common adapter interface behavior now comes from one place instead of 12 repeated method declarations across providers.

Why is this valuable?
It reduces maintenance overhead, prevents subtle divergence when adding/updating providers, and makes adapter contracts easier to reason about.

Implementation approach:

  • Shared adapter contract in proxy-utils

    • createAdapterMethods now returns shared getTargetHost(), getBasePath(), and default participatesInValidation alongside existing probe/models/reflection helpers.
  • Provider cleanup (targeted)

    • Removed duplicated method definitions from:
      • providers/anthropic.js
      • providers/gemini.js
      • providers/copilot.js
      • providers/openai.js
    • Preserved explicit OpenAI behavior (participatesInValidation: true) as an override.
  • Composition/order correctness

    • Adjusted OpenCode adapter spread ordering so its delegated runtime methods continue to override shared defaults where required.
  • Provider authoring guidance

    • Updated providers/ADDING-A-PROVIDER.md to document that these interface methods are supplied by createAdapterMethods.
// proxy-utils.js (shared adapter methods)
return {
  getTargetHost() { return rawTarget; },
  getBasePath() { return basePath; },
  participatesInValidation, // default derived in createAdapterMethods
  getValidationProbe: builtValidationProbe,
  getModelsFetchConfig: builtModelsFetchConfig,
  getReflectionInfo: builtReflectionInfo,
};

Copilot AI changed the title [WIP] Refactor provider adapters to eliminate duplicate methods Deduplicate provider adapter host/basePath/validation methods in shared adapter factory May 15, 2026
Copilot finished work on behalf of lpcox May 15, 2026 13:47
Copilot AI requested a review from lpcox May 15, 2026 13:47
@lpcox lpcox marked this pull request as ready for review May 15, 2026 13:53
@lpcox lpcox requested a review from Mossaka as a code owner May 15, 2026 13:53
Copilot AI review requested due to automatic review settings May 15, 2026 13:53
@github-actions

This comment has been minimized.

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 centralizes shared provider adapter interface methods in createAdapterMethods, reducing duplicated host/base-path/validation plumbing across API proxy providers.

Changes:

  • Adds shared getTargetHost, getBasePath, and default participatesInValidation behavior to proxy-utils.
  • Removes duplicate implementations from Anthropic, Gemini, Copilot, and OpenAI adapters while preserving OpenAI’s explicit validation override.
  • Updates OpenCode spread ordering and provider-authoring documentation.
Show a summary per file
File Description
containers/api-proxy/proxy-utils.js Extends shared adapter factory with host, base path, and validation participation fields.
containers/api-proxy/providers/anthropic.js Uses shared adapter methods instead of local duplicates.
containers/api-proxy/providers/gemini.js Uses shared adapter methods instead of local duplicates.
containers/api-proxy/providers/copilot.js Uses shared adapter methods instead of local duplicates.
containers/api-proxy/providers/openai.js Uses shared adapter methods while retaining explicit validation participation.
containers/api-proxy/providers/opencode.js Moves shared method spread before delegated overrides.
containers/api-proxy/providers/ADDING-A-PROVIDER.md Updates new-provider guidance to use shared adapter helpers.
containers/api-proxy/server.routing.test.js Adds coverage for shared host/base-path and validation defaults.

Copilot's findings

Tip

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

  • Files reviewed: 8/8 changed files
  • Comments generated: 1

skipModelsFetch,
modelsFetchHeaders = validationHeaders,
modelsCacheKey = provider,
participatesInValidation = !!apiKey,
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot mentioned this pull request May 15, 2026
@lpcox
Copy link
Copy Markdown
Collaborator

lpcox commented May 15, 2026

@copilot address review feedback

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 15, 2026

@copilot address review feedback

Addressed in d4e093e: added the missing JSDoc parameter entry for opts.participatesInValidation in createAdapterMethods (containers/api-proxy/proxy-utils.js) and validated with containers/api-proxy targeted routing tests.

Copilot finished work on behalf of lpcox May 15, 2026 14:36
@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results

  • ❌ GitHub API: gh pr list failed (HTTP 401: Bad credentials)
  • ✅ Playwright: GitHub.com navigation successful
  • ✅ File verify: smoke-test file found and valid

Result: 2/3 PASS — GitHub API check needs authentication troubleshooting

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smoke Test Results

Test Status
GitHub MCP connectivity ❌ 401 Bad credentials
GitHub.com HTTP connectivity ❌ Template vars not expanded
File write/read ❌ Template vars not expanded

Overall: FAIL — Workflow template variables (${{ steps.smoke-data.outputs.* }}) were not substituted before agent execution, and GitHub MCP returned 401. Pre-step data was unavailable for validation.

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Offline) Mode

Test Result
GitHub MCP connectivity ❌ 401 Bad credentials
GitHub.com HTTP connectivity ⚠️ Template vars unresolved (${{ steps.smoke-data.outputs.SMOKE_HTTP_CODE }})
File write/read ⚠️ Template vars unresolved — file path not injected
BYOK inference (api-proxy → api.githubcopilot.com) ✅ Responding in BYOK offline mode (COPILOT_OFFLINE=true)

Running in BYOK offline mode (COPILOT_OFFLINE=true) via api-proxy → api.githubcopilot.com.

Overall status: FAIL — GitHub MCP returned 401 and workflow template variables were not substituted before agent execution.

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Codex: FAIL
Merged PRs: Refactor api-proxy SIGTERM/SIGINT shutdown flow into a shared handler; Cap /reflect effective-token totals at configured maxEffectiveTokens
Queried PRs: fix(docker): apply docker-host-path-prefix to all compose service mounts; Fix issue duplication detector cache miss handling
GitHub MCP ❌; safeinputs-gh ❌; Playwright ✅; Tavily ❌
File write ✅; Bash read ✅; Discussion ✅; Build ✅
Overall status: FAIL

Warning

Firewall blocked 1 domain

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

  • registry.npmjs.org

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

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

@github-actions
Copy link
Copy Markdown
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.15.0 v20.20.2
Go go1.22.12 go1.22.12

Overall: FAILED — Python and Node.js versions differ between host and chroot environments.

Tested by Smoke Chroot

@github-actions
Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx All passed ✅ PASS
Node.js execa All passed ✅ PASS
Node.js p-limit All passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for issue #3210 · ● 5M ·

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results: FAIL. MCP missing, Connectivity OK, File IO OK.

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.

💎 Faceted by Smoke Gemini

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results — FAIL

Check Result
Redis PING ❌ Timeout/unreachable
PostgreSQL pg_isready ❌ No response
PostgreSQL SELECT 1 ❌ Not attempted (pg_isready failed)

Overall: FAILhost.docker.internal services are not reachable from this runner.

🔌 Service connectivity validated by Smoke Services

@lpcox lpcox merged commit a43126f into main May 15, 2026
65 of 69 checks passed
@lpcox lpcox deleted the copilot/fix-duplicate-provider-methods branch May 15, 2026 15:12
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.

[Duplicate Code] Provider adapter objects repeat identical getTargetHost / getBasePath / participatesInValidation methods across 4 providers

3 participants