Deduplicate provider adapter host/basePath/validation methods in shared adapter factory#3210
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
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 defaultparticipatesInValidationbehavior toproxy-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, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@copilot address review feedback |
Addressed in |
Smoke Test Results
Result: 2/3 PASS — GitHub API check needs authentication troubleshooting
|
🔍 Smoke Test Results
Overall: FAIL — Workflow template variables (
|
Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( Overall status: FAIL — GitHub MCP returned 401 and workflow template variables were not substituted before agent execution.
|
|
Smoke Codex: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
Chroot Version Comparison Results
Overall: FAILED — Python and Node.js versions differ between host and chroot environments.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
|
Smoke Test Results: FAIL. MCP missing, Connectivity OK, File IO OK. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
Smoke Test Results — FAIL
Overall: FAIL —
|
✨ 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 increateAdapterMethodsand 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-utilscreateAdapterMethodsnow returns sharedgetTargetHost(),getBasePath(), and defaultparticipatesInValidationalongside existing probe/models/reflection helpers.Provider cleanup (targeted)
providers/anthropic.jsproviders/gemini.jsproviders/copilot.jsproviders/openai.jsparticipatesInValidation: true) as an override.Composition/order correctness
Provider authoring guidance
providers/ADDING-A-PROVIDER.mdto document that these interface methods are supplied bycreateAdapterMethods.