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
Streaming tool detection: guard late tool_calls, filter incomplete fragments (#4648)
Daniel Han9d68621614b5
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.pyindex 8a0d1c0962f..2b4ed3b2e6d 100644--- a/studio/backend/core/inference/llama_cpp.py+++ b/studio/backend/core/inference/llama_cpp.py@@ -2135,6 +2135,11 @@ class LlamaCppBackend:# ── Structured tool_calls ──tc_deltas = delta.get("tool_calls")if tc_deltas:+ # Once visible content has been+ # emitted, do not reclassify this+ # turn as a tool call.+ if _last_emitted:+ continuehas_structured_tc = Truedetect_state = _S_DRAININGfor tc_d in tc_deltas:@@ -2362,7 +2367,18 @@ class LlamaCppBackend:tool_calls = Nonecontent_text = content_accumif has_structured_tc:- tool_calls = [tool_calls_acc[i] for i in sorted(tool_calls_acc)]+ # Filter out incomplete fragments (e.g. from+ # truncation by max_tokens or disconnect).+ tool_calls = [+ tool_calls_acc[i]+ for i in sorted(tool_calls_acc)+ if (+ tool_calls_acc[i]+ .get("function", {})+ .get("name", "")+ .strip()+ )+ ] or Noneif (not tool_callsand auto_heal_tool_calls