From 71d355ec445f6c7b0855059def2b2e18756ec1d5 Mon Sep 17 00:00:00 2001 From: Varun Chawla Date: Sat, 7 Feb 2026 20:12:08 -0800 Subject: [PATCH] fix: normalize hyphenated model IDs for LM Studio tool support LM Studio uses hyphenated model identifiers (e.g., "Meta-Llama-3.1-8B-Instruct-GGUF"), but the Ollama heuristic checks for non-hyphenated patterns like "llama3.1". This fix normalizes hyphenated model names by removing hyphens before delegating to Ollama's tool support logic, enabling agent mode for LM Studio models with hyphenated IDs. Added comprehensive tests for hyphenated model names including: - Meta-Llama-3.1-8B-Instruct-GGUF - Qwen2-7B-Instruct - Mixtral-8x7B-Instruct-v0.1 - Case insensitivity checks - Negative tests for unsupported models like "Llama-Vision-Free" Addresses feedback from Cubic AI bot review. --- core/llm/toolSupport.test.ts | 21 +++++++++++++++++++++ core/llm/toolSupport.ts | 7 ++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/core/llm/toolSupport.test.ts b/core/llm/toolSupport.test.ts index 308d3ae7e..7d68e8615 100644 --- a/core/llm/toolSupport.test.ts +++ b/core/llm/toolSupport.test.ts @@ -288,17 +288,38 @@ describe("PROVIDER_TOOL_SUPPORT", () => { expect(supportsFn("mistral-7b")).toBe(true); }); + it("should return true for LM Studio hyphenated model IDs", () => { + // LM Studio uses hyphenated model identifiers like "Meta-Llama-3.1-8B-Instruct-GGUF" + expect(supportsFn("Meta-Llama-3.1-8B-Instruct-GGUF")).toBe(true); + expect(supportsFn("Meta-Llama-3.2-3B-Instruct")).toBe(true); + expect(supportsFn("Qwen2-7B-Instruct")).toBe(true); + expect(supportsFn("Mixtral-8x7B-Instruct-v0.1")).toBe(true); + expect(supportsFn("Mistral-7B-Instruct-v0.2")).toBe(true); + expect(supportsFn("llama-3.1-8b-instruct")).toBe(true); + }); + it("should return false for explicitly unsupported models (same as ollama)", () => { expect(supportsFn("vision")).toBe(false); expect(supportsFn("math")).toBe(false); expect(supportsFn("guard")).toBe(false); }); + it("should return false for hyphenated unsupported model names", () => { + expect(supportsFn("Llama-Vision-Free")).toBe(false); + expect(supportsFn("Math-Solver-7B")).toBe(false); + expect(supportsFn("Guard-Model")).toBe(false); + }); + it("should handle case insensitivity (same as ollama)", () => { expect(supportsFn("LLAMA3.1")).toBe(true); expect(supportsFn("MIXTRAL-8x7b")).toBe(true); expect(supportsFn("VISION")).toBe(false); }); + + it("should handle case insensitivity with hyphenated names", () => { + expect(supportsFn("META-LLAMA-3.1-8B-INSTRUCT")).toBe(true); + expect(supportsFn("Qwen2-7B-Instruct-GGUF")).toBe(true); + }); }); describe("xAI", () => { diff --git a/core/llm/toolSupport.ts b/core/llm/toolSupport.ts index 818626c6a..79302717b 100644 --- a/core/llm/toolSupport.ts +++ b/core/llm/toolSupport.ts @@ -189,7 +189,12 @@ export const PROVIDER_TOOL_SUPPORT: Record boolean> = return false; }, - lmstudio: (model) => PROVIDER_TOOL_SUPPORT["ollama"](model), + lmstudio: (model) => { + // LM Studio uses hyphenated model IDs (e.g., "Meta-Llama-3.1-8B-Instruct-GGUF") + // Convert to format that matches Ollama's heuristic (e.g., "llama3.1") + const normalized = model.toLowerCase().replace(/-/g, ""); + return PROVIDER_TOOL_SUPPORT["ollama"](normalized); + }, sambanova: (model) => { // https://docs.sambanova.ai/cloud/docs/capabilities/function-calling if (