Skip to content

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.

fix(studio): improve tool-calling re-prompt for small models (#4783)

Daniel Han4f9986ecb991
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py
index b436f4dc6d8..44c700bf3d5 100644
--- a/studio/backend/core/inference/llama_cpp.py
+++ b/studio/backend/core/inference/llama_cpp.py
@@ -45,8 +45,8 @@ _INTENT_SIGNAL = re.compile(
r"\b(?:now i|next i)\b"
r")"
)
-_MAX_REPROMPTS = 1
-_REPROMPT_MAX_CHARS = 500
+_MAX_REPROMPTS = 3
+_REPROMPT_MAX_CHARS = 2000
# ── Pre-compiled patterns for GGUF shard detection ───────────
_SHARD_FULL_RE = re.compile(r"^(.*)-(\d{5})-of-(\d{5})\.gguf$")
@@ -2659,8 +2659,9 @@ class LlamaCppBackend:
{
"role": "user",
"content": (
- "Please use the available tools to complete "
- "the task instead of describing what to do."
+ "STOP. Do NOT write code or explain. "
+ "You MUST call a tool NOW. "
+ "Call web_search or python immediately."
),
}
)
diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py
index 8f058bd0f2e..ced24c1d5f5 100644
--- a/studio/backend/routes/inference.py
+++ b/studio/backend/routes/inference.py
@@ -96,8 +96,10 @@ router = APIRouter()
# Appended to tool-use nudge to discourage plan-without-action
_TOOL_ACTION_NUDGE = (
- " Always call tools directly."
+ " IMPORTANT: Always call tools directly -- never write code yourself."
" Never describe what you plan to do -- just call the tool immediately."
+ " For any code request, call the python tool. For any factual question, call web_search."
+ " Do NOT output code blocks -- use the python tool instead."
)
# Regex for stripping leaked tool-call XML from assistant messages/stream