Skip to content

Commit aab87ec

Browse files
justinhuangcodeclaude
authored andcommitted
fix(agents): scope volcengine-plan/byteplus-plan auth lookup to profile resolution
The configure flow stores auth credentials under `provider: "volcengine"`, but the coding model uses `volcengine-plan` as its provider. Add a scoped `normalizeProviderIdForAuth` function used only by `listProfilesForProvider` so coding-plan variants resolve to their base provider for auth credential lookup without affecting global provider routing. Closes #31731 Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent a71b8d2 commit aab87ec

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/agents/auth-profiles/profiles.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { normalizeSecretInput } from "../../utils/normalize-secret-input.js";
2-
import { normalizeProviderId } from "../model-selection.js";
2+
import { normalizeProviderId, normalizeProviderIdForAuth } from "../model-selection.js";
33
import {
44
ensureAuthProfileStore,
55
saveAuthProfileStore,
@@ -79,9 +79,9 @@ export async function upsertAuthProfileWithLock(params: {
7979
}
8080

8181
export function listProfilesForProvider(store: AuthProfileStore, provider: string): string[] {
82-
const providerKey = normalizeProviderId(provider);
82+
const providerKey = normalizeProviderIdForAuth(provider);
8383
return Object.entries(store.profiles)
84-
.filter(([, cred]) => normalizeProviderId(cred.provider) === providerKey)
84+
.filter(([, cred]) => normalizeProviderIdForAuth(cred.provider) === providerKey)
8585
.map(([id]) => id);
8686
}
8787

src/agents/model-selection.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
buildModelAliasIndex,
99
normalizeModelSelection,
1010
normalizeProviderId,
11+
normalizeProviderIdForAuth,
1112
modelKey,
1213
resolveAllowedModelRef,
1314
resolveConfiguredModelRef,
@@ -64,6 +65,14 @@ describe("model-selection", () => {
6465
});
6566
});
6667

68+
describe("normalizeProviderIdForAuth", () => {
69+
it("maps coding-plan variants to base provider for auth lookup", () => {
70+
expect(normalizeProviderIdForAuth("volcengine-plan")).toBe("volcengine");
71+
expect(normalizeProviderIdForAuth("byteplus-plan")).toBe("byteplus");
72+
expect(normalizeProviderIdForAuth("openai")).toBe("openai");
73+
});
74+
});
75+
6776
describe("parseModelRef", () => {
6877
it("should parse full model refs", () => {
6978
expect(parseModelRef("anthropic/claude-3-5-sonnet", "openai")).toEqual({

src/agents/model-selection.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ export function normalizeProviderId(provider: string): string {
6161
return normalized;
6262
}
6363

64+
/** Normalize provider ID for auth lookup. Coding-plan variants share auth with base. */
65+
export function normalizeProviderIdForAuth(provider: string): string {
66+
const normalized = normalizeProviderId(provider);
67+
if (normalized === "volcengine-plan") {
68+
return "volcengine";
69+
}
70+
if (normalized === "byteplus-plan") {
71+
return "byteplus";
72+
}
73+
return normalized;
74+
}
75+
6476
export function findNormalizedProviderValue<T>(
6577
entries: Record<string, T> | undefined,
6678
provider: string,

0 commit comments

Comments
 (0)