Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/opencode/src/plugin/copilot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ export async function CopilotAuthPlugin(input: PluginInput): Promise<Hooks> {
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: {
Expand Down
2 changes: 1 addition & 1 deletion packages/opencode/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("@")
Expand Down
11 changes: 11 additions & 0 deletions packages/opencode/src/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Loading