diff --git a/packages/opencode/src/plugin/copilot.ts b/packages/opencode/src/plugin/copilot.ts index 39ea0d00d28e..041de1db2ab0 100644 --- a/packages/opencode/src/plugin/copilot.ts +++ b/packages/opencode/src/plugin/copilot.ts @@ -308,6 +308,11 @@ export async function CopilotAuthPlugin(input: PluginInput): Promise { output.headers["anthropic-beta"] = "interleaved-thinking-2025-05-14" } + // Skip x-initiator override when using @ai-sdk/github-copilot - it has its own + // fetch wrapper that sets x-initiator based on message content, and overriding + // it here causes "invalid initiator" validation errors from Copilot API + if (incoming.model.api.npm === "@ai-sdk/github-copilot") return + const session = await sdk.session .get({ path: { diff --git a/packages/opencode/src/plugin/index.ts b/packages/opencode/src/plugin/index.ts index 24dc695d6350..040dc11d783e 100644 --- a/packages/opencode/src/plugin/index.ts +++ b/packages/opencode/src/plugin/index.ts @@ -53,7 +53,7 @@ export namespace Plugin { for (let plugin of plugins) { // ignore old codex plugin since it is supported first party now - if (plugin.includes("opencode-openai-codex-auth") || plugin.includes("opencode-copilot-auth")) continue + if (plugin.includes("opencode-openai-codex-auth")) continue log.info("loading plugin", { path: plugin }) if (!plugin.startsWith("file://")) { const lastAtIndex = plugin.lastIndexOf("@") diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts index 44bcf8adb3de..1e0ecf3a33b5 100644 --- a/packages/opencode/src/provider/provider.ts +++ b/packages/opencode/src/provider/provider.ts @@ -837,6 +837,17 @@ export namespace Provider { database[providerID] = parsed } + // Force github-copilot models to use @ai-sdk/github-copilot instead of @ai-sdk/openai-compatible. + // Models like gpt-5.3-codex require the /responses endpoint, which only @ai-sdk/github-copilot supports. + // This must run after config processing to catch user-defined models not present in models.dev. + for (const providerID of ["github-copilot", "github-copilot-enterprise"]) { + if (database[providerID]) { + for (const model of Object.values(database[providerID].models)) { + model.api.npm = "@ai-sdk/github-copilot" + } + } + } + // load env const env = Env.all() for (const [providerID, provider] of Object.entries(database)) {