Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: keep GGUF compaction when the catalog row goes stale (#10158)
Kenshi7da85a03c60e
diff --git a/studio/frontend/src/features/chat/api/chat-adapter.ts b/studio/frontend/src/features/chat/api/chat-adapter.tsindex 630b81e5f8d..5994e2e8d8f 100644--- a/studio/frontend/src/features/chat/api/chat-adapter.ts+++ b/studio/frontend/src/features/chat/api/chat-adapter.ts@@ -23,6 +23,7 @@ import {} from "@/features/hub/inventory/api";import { isHiddenModelId } from "@/features/hub/lib/hidden-models";import {+ isServedByLlamaCpp,isServedByMlx,loadedContextFields,resolveInitialConfig,@@ -2169,6 +2170,7 @@ type QueuedResolvedModelRuntime = {supportsPreserveThinking: boolean;preserveThinking: boolean;loadedContextLength: number | null;+ loadedIsGguf: boolean | null;loadedIsMultimodal: boolean;modelCapabilities: QueuedModelCapabilities | null;};@@ -2316,6 +2318,7 @@ function queuedResolvedModelFromStore(supportsPreserveThinking: state.supportsPreserveThinking,preserveThinking: state.preserveThinking,loadedContextLength: state.loadedContextLength,+ loadedIsGguf: state.loadedIsGguf,loadedIsMultimodal: state.loadedIsMultimodal,modelCapabilities: activeModel? {@@ -3900,6 +3903,7 @@ async function resolveQueuedEmptyLocalModel(abortSignal: AbortSignal): Promise<{status.supports_preserve_thinking ?? false,preserveThinking: resolvePreserveThinkingOnLoad(status),loadedContextLength: loadedContextFields(status).loadedContextLength,+ loadedIsGguf: loadedContextFields(status).loadedIsGguf,loadedIsMultimodal: isMultimodalResponse(status),modelCapabilities: {isVision: status.is_vision ?? false,@@ -4131,6 +4135,7 @@ export function createOpenAIStreamAdapter(queuedEmptyModelRuntime.supportsPreserveThinking,preserveThinking: queuedEmptyModelRuntime.preserveThinking,loadedContextLength: queuedEmptyModelRuntime.loadedContextLength,+ loadedIsGguf: queuedEmptyModelRuntime.loadedIsGguf,models: mergeQueuedModelCapabilities(base.models,queuedEmptyModelRuntime.checkpoint,@@ -4525,6 +4530,10 @@ export function createOpenAIStreamAdapter(queuedEmptyModelRuntime !== null? queuedEmptyModelRuntime.loadedContextLength: liveRuntime.loadedContextLength,+ loadedIsGguf:+ queuedEmptyModelRuntime !== null+ ? queuedEmptyModelRuntime.loadedIsGguf+ : liveRuntime.loadedIsGguf,loadedIsMultimodal:queuedEmptyModelRuntime?.loadedIsMultimodal ??liveRuntime.loadedIsMultimodal,@@ -4991,6 +5000,16 @@ export function createOpenAIStreamAdapter(const activeModel = runtime.models.find((m) => m.id === params.checkpoint,);+ // The same owner the settings panel asks, so the body and the panel cannot disagree+ // about the model they both describe. A catalog row would: /api/models/list can+ // replace the row a load minted, and the variant / native path token still classify+ // a GGUF the backend has not answered for yet.+ const isGgufForCompaction = isServedByLlamaCpp({+ loadedIsGguf: runtime.loadedIsGguf,+ activeGgufVariant: runtime.activeGgufVariant,+ activeNativePathToken: runtime.activeNativePathToken,+ checkpoint: params.checkpoint,+ });const generationUserMessage = [...survivingMessages].reverse().find((message) => message.role === "user");@@ -6087,7 +6106,7 @@ export function createOpenAIStreamAdapter(// Opt into the trailing usage chunk so the context bar and tok/s populate (backend gates it).stream_options: { include_usage: true },...ggufCompactionRequestFields({- isGguf: activeModel?.isGguf === true,+ isGguf: isGgufForCompaction,autoCompactEnabled: runtime.autoCompactEnabled,contextPolicy: runtime.contextPolicy,compactionHeadroomRatio: runtime.compactionHeadroomRatio,diff --git a/studio/frontend/src/features/chat/utils/queued-chat-run-settings.ts b/studio/frontend/src/features/chat/utils/queued-chat-run-settings.tsindex 4580d78b5c5..e1a6df06f2d 100644--- a/studio/frontend/src/features/chat/utils/queued-chat-run-settings.ts+++ b/studio/frontend/src/features/chat/utils/queued-chat-run-settings.ts@@ -34,6 +34,11 @@ const QUEUED_SETTING_KEYS = ["ragAutoInject","ragAutoInjectMinScore","loadedContextLength",+ // Beside the window it describes: selecting an external model clears the live residency+ // fields without unloading, and a queued local turn is still served by the model it was+ // queued against. Without this an Ollama or native-path GGUF, which reports no quant and+ // no .gguf suffix, reads as non-GGUF and loses its compaction policy.+ "loadedIsGguf","autoHealToolCalls","nudgeToolCalls","maxToolCallsPerMessage",diff --git a/studio/frontend/tests/auto-compaction-settings.test.ts b/studio/frontend/tests/auto-compaction-settings.test.tsindex 746e2351e66..92386143d41 100644--- a/studio/frontend/tests/auto-compaction-settings.test.ts+++ b/studio/frontend/tests/auto-compaction-settings.test.ts@@ -114,4 +114,74 @@ test("unsupported headroom ratios snap to an exposed choice", () => {test("the chat adapter sends compaction fields through the shared helper", () => {const adapter = readSrc("features/chat/api/chat-adapter.ts");assert.match(adapter, /ggufCompactionRequestFields\(/);+ // Through isServedByLlamaCpp, not a catalog row: /api/models/list can replace the row a+ // load minted, and the panel that shows these settings asks the same owner.+ assert.match(adapter, /isGguf: isGgufForCompaction/);+ assert.match(adapter, /loadedIsGguf: runtime\.loadedIsGguf/);+ assert.match(adapter, /isServedByLlamaCpp\(/);+ // One request object for both streams, so a media turn cannot lose these fields.+ assert.match(adapter, /image_base64: imageBase64/);+});++test("a queued run keeps its own model's llama.cpp verdict after the picker moves on", async () => {+ const { registerBundlerResolver, installLocalStorageFake } = await import(+ "./helpers/kit.ts"+ );+ registerBundlerResolver();+ installLocalStorageFake();+ const { snapshotQueuedChatRunSettings } = await import(+ "../src/features/chat/utils/queued-chat-run-settings.ts"+ );+ const { isServedByLlamaCpp, loadedContextFields } = await import(+ "../src/features/model-picker/model-config/per-model-config.ts"+ );++ // An Ollama GGUF: the backend keeps the opaque inventory ref public, so the checkpoint+ // carries no .gguf suffix, and the load reports no quant. loadedIsGguf is the only+ // evidence llama.cpp serves it.+ const resident = {+ params: { checkpoint: "ollama-manifest:%2Fhome%2Fu%2F.ollama%2Fmanifests%2Fq" },+ activeGgufVariant: null,+ activeNativePathToken: null,+ loadedIsGguf: true,+ loadedContextLength: 8192,+ autoCompactEnabled: true,+ contextPolicy: "rolling" as const,+ compactionHeadroomRatio: 0.1,+ };+ const queued = snapshotQueuedChatRunSettings(+ resident as unknown as Parameters<typeof snapshotQueuedChatRunSettings>[0],+ );++ // Selecting an external provider clears the local residency fields without unloading+ // the model that the queued turn is still going to be served by.+ const live = {+ ...resident,+ params: { checkpoint: "external::openai::gpt-5" },+ activeGgufVariant: null,+ activeNativePathToken: null,+ ...loadedContextFields(null),+ };+ const runtime = { ...live, ...queued };++ const isGguf = isServedByLlamaCpp({+ loadedIsGguf: runtime.loadedIsGguf,+ activeGgufVariant: runtime.activeGgufVariant,+ activeNativePathToken: runtime.activeNativePathToken,+ checkpoint: runtime.params.checkpoint,+ });+ assert.equal(isGguf, true);+ assert.deepEqual(+ ggufCompactionRequestFields({+ isGguf,+ autoCompactEnabled: runtime.autoCompactEnabled,+ contextPolicy: runtime.contextPolicy,+ compactionHeadroomRatio: runtime.compactionHeadroomRatio,+ }),+ {+ context_overflow: "truncate_oldest",+ context_policy: "rolling",+ compaction_headroom_ratio: 0.1,+ },+ );});diff --git a/studio/frontend/tests/chat-sampling-seed.test.ts b/studio/frontend/tests/chat-sampling-seed.test.tsindex ce368f62fc1..554d3ffa88a 100644--- a/studio/frontend/tests/chat-sampling-seed.test.ts+++ b/studio/frontend/tests/chat-sampling-seed.test.ts@@ -287,9 +287,10 @@ test("the request drops a seed the loaded model cannot use", () => {// A pin set on a GGUF outlives a switch to transformers, where the panel hides the// field: without this the user would keep sending a seed they can no longer see.assert.match(adapter, /!modelReadsSamplingSeed\(/);- // The same summary the body already reads isGguf from for context_overflow, so- // "is this a GGUF" cannot be answered two ways inside one request.- assert.match(adapter, /activeModel\?\.isGguf === true/);+ // The same summary chat-settings-sheet passes when it decides whether to show the field,+ // so the panel cannot offer a seed the body drops. Not the compaction gate: that one asks+ // isServedByLlamaCpp, which answers for llama.cpp alone, and MLX reads a seed too.+ assert.match(adapter, /modelReadsSamplingSeed\(activeModel\)/);});test("the seed belongs to the chat, not the installation", () => {@@ -339,7 +340,10 @@ type _EveryFlagTheSeedGateReadsIsRequired = Assert<: false>;+const everyFlagTheSeedGateReads: _EveryFlagTheSeedGateReadsIsRequired = true;+test("a models[] row states every flag the seed gate reads", () => {+ assert.equal(everyFlagTheSeedGateReads, true);const row: ChatModelRow = {id: "m",name: "m",diff --git a/studio/frontend/tests/rolling-context-window.test.ts b/studio/frontend/tests/rolling-context-window.test.tsindex bc202abc2f8..c2e95590797 100644--- a/studio/frontend/tests/rolling-context-window.test.ts+++ b/studio/frontend/tests/rolling-context-window.test.ts@@ -20,7 +20,8 @@ const adapter = readSrc("features/chat/api/chat-adapter.ts");const transport = readSrc("features/chat/api/chat-api.ts");test("local chat opts into the rolling context policy", () => {- assert.match(adapter, /isGguf === true/);+ assert.match(adapter, /isGgufForCompaction/);+ assert.match(adapter, /runtime\.loadedIsGguf/);assert.match(adapter, /autoCompactEnabled/);assert.match(adapter, /ggufCompactionRequestFields\(/);assert.match(adapter, /This conversation was compacted/);@@ -119,7 +120,7 @@ test("a record with no boundary never guesses one from a summed drop count", ()test("a rescued turn cannot silence the compactions that follow it", () => {// The `showsNotice` scan in thread.tsx, which only announces a boundary that ROSE.- const boundariesShown = (records: any[]) => {+ const boundariesShown = (records: ContextTruncation[]) => {let high = 0;const shown: number[] = [];records.forEach((rec, index) => {diff --git a/tests/studio/test_multi_chat_prompt_queue_contract.py b/tests/studio/test_multi_chat_prompt_queue_contract.pyindex 352d66f7096..f566f037895 100644--- a/tests/studio/test_multi_chat_prompt_queue_contract.py+++ b/tests/studio/test_multi_chat_prompt_queue_contract.py@@ -474,6 +474,8 @@ def test_queued_settings_are_thread_scoped_without_cross_chat_fallback():assert "liveRuntime.supportsTools" in auto_load_mergeassert "liveRuntime.supportsReasoning" in auto_load_mergeassert "liveRuntime.loadedContextLength" in auto_load_merge+ assert "queuedEmptyModelRuntime.loadedIsGguf" in auto_load_merge+ assert "liveRuntime.loadedIsGguf" in auto_load_mergeassert "isExternalModelId(visibleState.params.checkpoint)" in CHAT_ADAPTERassert "resolveInferenceCheckpointId(status)" in CHAT_ADAPTERassert "skipAdoptServerModel: true" in CHAT_ADAPTER@@ -601,6 +603,8 @@ def test_queued_settings_are_thread_scoped_without_cross_chat_fallback():QUEUED_MODEL_CAPABILITIES)assert "loadedIsMultimodal: state.loadedIsMultimodal" in CHAT_ADAPTER+ assert "loadedIsGguf: state.loadedIsGguf" in CHAT_ADAPTER+ assert "loadedIsGguf: loadedContextFields(status).loadedIsGguf" in lifecycleassert "queuedEmptyModelRuntime?.loadedIsMultimodal" in auto_load_mergeassert "usesLocalModel:" in targetassert "usePromptQueueUI.getState().byThreadId" in CONFIRM_MODEL_SWAP