fix(native-llm): prefer console opencode token (#28237)

This commit is contained in:
Kit Langton 2026-05-18 17:23:57 -04:00 committed by GitHub
parent ef9e567e5f
commit 8a321c4536
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 6 deletions

View file

@ -292,6 +292,34 @@ describe("session.llm-native.request", () => {
).toEqual({ type: "unsupported", reason: "OpenAI API key is not configured" })
})
test("prefers console provider api key over stored opencode auth", () => {
expect(
LLMNativeRuntime.status({
model: { ...baseModel, providerID: ProviderID.make("opencode") },
provider: {
...providerInfo,
id: ProviderID.make("opencode"),
options: { apiKey: "console-token" },
key: "zen-token",
},
auth: { type: "api", key: "zen-token" },
}),
).toMatchObject({
type: "supported",
apiKey: "console-token",
})
expect(
LLMNativeRuntime.status({
model: baseModel,
provider: { ...providerInfo, options: {}, key: "provider-key" },
auth: undefined,
}),
).toMatchObject({
type: "supported",
apiKey: "provider-key",
})
})
test("native tool wrapper converts thrown errors into typed ToolFailure", async () => {
const wrapped = LLMNativeRuntime.nativeTools(
{