























@@ -50,7 +50,7 @@ describe("openrouter-model-capabilities", () => {
5050id: "acme/top-level-max-completion",
5151name: "Top Level Max Completion",
5252architecture: { modality: "text+image->text" },
53-supported_parameters: ["reasoning"],
53+supported_parameters: ["reasoning", "tools"],
5454context_length: 65432,
5555max_completion_tokens: 12345,
5656pricing: { prompt: "0.000001", completion: "0.000002" },
@@ -79,17 +79,60 @@ describe("openrouter-model-capabilities", () => {
7979const maxCompletion = module.getOpenRouterModelCapabilities("acme/top-level-max-completion");
8080expect(maxCompletion?.input).toEqual(["text", "image"]);
8181expect(maxCompletion?.reasoning).toBe(true);
82+expect(maxCompletion?.supportsTools).toBe(true);
8283expect(maxCompletion?.contextWindow).toBe(65432);
8384expect(maxCompletion?.maxTokens).toBe(12345);
84858586const maxOutput = module.getOpenRouterModelCapabilities("acme/top-level-max-output");
8687expect(maxOutput?.input).toEqual(["text", "image"]);
8788expect(maxOutput?.reasoning).toBe(false);
89+expect(maxOutput?.supportsTools).toBeUndefined();
8890expect(maxOutput?.contextWindow).toBe(54321);
8991expect(maxOutput?.maxTokens).toBe(23456);
9092});
9193});
929495+it("preserves explicit OpenRouter tool support metadata", async () => {
96+await withOpenRouterStateDir(async () => {
97+vi.stubGlobal(
98+"fetch",
99+vi.fn(
100+async () =>
101+new Response(
102+JSON.stringify({
103+data: [
104+{
105+id: "perplexity/sonar-deep-research",
106+name: "Sonar Deep Research",
107+supported_parameters: ["reasoning", "web_search_options"],
108+},
109+{
110+id: "google/gemini-2.5-pro",
111+name: "Gemini 2.5 Pro",
112+supported_parameters: ["reasoning", "tools"],
113+},
114+],
115+}),
116+{
117+status: 200,
118+headers: { "content-type": "application/json" },
119+},
120+),
121+),
122+);
123+124+const module = await importOpenRouterModelCapabilities("tool-support");
125+await module.loadOpenRouterModelCapabilities("perplexity/sonar-deep-research");
126+127+expect(
128+module.getOpenRouterModelCapabilities("perplexity/sonar-deep-research")?.supportsTools,
129+).toBe(false);
130+expect(module.getOpenRouterModelCapabilities("google/gemini-2.5-pro")?.supportsTools).toBe(
131+true,
132+);
133+});
134+});
135+93136it("does not refetch immediately after an awaited miss for the same model id", async () => {
94137await withOpenRouterStateDir(async () => {
95138const fetchSpy = vi.fn(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。