





























@@ -4,6 +4,7 @@ import type { ModelCatalogEntry } from "../../agents/model-catalog.js";
44import type { OpenClawConfig } from "../../config/config.js";
5566let mockStore: AuthProfileStore;
7+let mockAgentStore: AuthProfileStore | undefined;
78let mockAllowedProfiles: string[];
89const loadModelCatalogMock = vi.fn<() => Promise<ModelCatalogEntry[]>>(async () => []);
910@@ -73,9 +74,10 @@ vi.mock("./shared.js", () => ({
7374}));
74757576vi.mock("../../agents/auth-profiles.js", () => ({
76-ensureAuthProfileStore: () => mockStore,
77-listProfilesForProvider: (_store: AuthProfileStore, provider: string) =>
78-Object.entries(mockStore.profiles)
77+ensureAuthProfileStore: (agentDir?: string) =>
78+agentDir === "/tmp/coder-agent" && mockAgentStore ? mockAgentStore : mockStore,
79+listProfilesForProvider: (store: AuthProfileStore, provider: string) =>
80+Object.entries(store.profiles)
7981.filter(
8082([, profile]) =>
8183typeof profile.provider === "string" && profile.provider.toLowerCase() === provider,
@@ -198,6 +200,7 @@ describe("buildProbeTargets reason codes", () => {
198200anthropic: ["anthropic:default"],
199201},
200202};
203+mockAgentStore = undefined;
201204mockAllowedProfiles = [];
202205loadModelCatalogMock.mockReset();
203206loadModelCatalogMock.mockResolvedValue([]);
@@ -378,4 +381,56 @@ describe("buildProbeTargets reason codes", () => {
378381}),
379382);
380383});
384+385+it("uses the requested agent auth store when building profile probe targets", async () => {
386+mockStore = {
387+version: 1,
388+profiles: {},
389+order: {},
390+};
391+mockAgentStore = {
392+version: 1,
393+profiles: {
394+"anthropic:coder": {
395+type: "api_key",
396+provider: "anthropic",
397+key: "sk-ant-coder-profile",
398+},
399+},
400+order: {},
401+};
402+403+const defaultPlan = await buildProbeTargets({
404+cfg: {} as OpenClawConfig,
405+providers: ["anthropic"],
406+modelCandidates: ["anthropic/claude-sonnet-4-6"],
407+options: {
408+timeoutMs: 5_000,
409+concurrency: 1,
410+maxTokens: 16,
411+},
412+});
413+const agentPlan = await buildProbeTargets({
414+cfg: {} as OpenClawConfig,
415+agentDir: "/tmp/coder-agent",
416+providers: ["anthropic"],
417+modelCandidates: ["anthropic/claude-sonnet-4-6"],
418+options: {
419+timeoutMs: 5_000,
420+concurrency: 1,
421+maxTokens: 16,
422+},
423+});
424+425+expect(defaultPlan.targets).toEqual([]);
426+expect(agentPlan.results).toEqual([]);
427+expect(agentPlan.targets).toHaveLength(1);
428+expect(agentPlan.targets[0]).toEqual(
429+expect.objectContaining({
430+provider: "anthropic",
431+profileId: "anthropic:coder",
432+source: "profile",
433+}),
434+);
435+});
381436});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。