summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authoradamelmore <[email protected]>2026-01-25 19:40:28 -0600
committerAdam <[email protected]>2026-01-25 20:40:00 -0600
commit5993a098b4b1ec245c0795f4f79ab2fef1213487 (patch)
tree577f77083db9914ae905c3deca29838ec1118c07
parentc323d96deb3f1d98bc62160f4e954aad1a807253 (diff)
downloadopencode-5993a098b4b1ec245c0795f4f79ab2fef1213487.tar.gz
opencode-5993a098b4b1ec245c0795f4f79ab2fef1213487.zip
fix(core): don't override source in custom provider loaders
-rw-r--r--packages/opencode/src/provider/provider.ts23
-rw-r--r--packages/opencode/test/provider/provider.test.ts7
2 files changed, 15 insertions, 15 deletions
diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts
index fdd4ccdfb..f898d3be4 100644
--- a/packages/opencode/src/provider/provider.ts
+++ b/packages/opencode/src/provider/provider.ts
@@ -854,10 +854,9 @@ export namespace Provider {
// Load for the main provider if auth exists
if (auth) {
const options = await plugin.auth.loader(() => Auth.get(providerID) as any, database[plugin.auth.provider])
- mergeProvider(plugin.auth.provider, {
- source: "custom",
- options: options,
- })
+ const opts = options ?? {}
+ const patch: Partial<Info> = providers[providerID] ? { options: opts } : { source: "custom", options: opts }
+ mergeProvider(providerID, patch)
}
// If this is github-copilot plugin, also register for github-copilot-enterprise if auth exists
@@ -870,10 +869,11 @@ export namespace Provider {
() => Auth.get(enterpriseProviderID) as any,
database[enterpriseProviderID],
)
- mergeProvider(enterpriseProviderID, {
- source: "custom",
- options: enterpriseOptions,
- })
+ const opts = enterpriseOptions ?? {}
+ const patch: Partial<Info> = providers[enterpriseProviderID]
+ ? { options: opts }
+ : { source: "custom", options: opts }
+ mergeProvider(enterpriseProviderID, patch)
}
}
}
@@ -889,10 +889,9 @@ export namespace Provider {
const result = await fn(data)
if (result && (result.autoload || providers[providerID])) {
if (result.getModel) modelLoaders[providerID] = result.getModel
- mergeProvider(providerID, {
- source: "custom",
- options: result.options,
- })
+ const opts = result.options ?? {}
+ const patch: Partial<Info> = providers[providerID] ? { options: opts } : { source: "custom", options: opts }
+ mergeProvider(providerID, patch)
}
}
diff --git a/packages/opencode/test/provider/provider.test.ts b/packages/opencode/test/provider/provider.test.ts
index 8a2009646..482587d8a 100644
--- a/packages/opencode/test/provider/provider.test.ts
+++ b/packages/opencode/test/provider/provider.test.ts
@@ -46,9 +46,10 @@ test("provider loaded from env variable", async () => {
fn: async () => {
const providers = await Provider.list()
expect(providers["anthropic"]).toBeDefined()
- // Note: source becomes "custom" because CUSTOM_LOADERS run after env loading
- // and anthropic has a custom loader that merges additional options
- expect(providers["anthropic"].source).toBe("custom")
+ // Provider should retain its connection source even if custom loaders
+ // merge additional options.
+ expect(providers["anthropic"].source).toBe("env")
+ expect(providers["anthropic"].options.headers["anthropic-beta"]).toBeDefined()
},
})
})