unsloth/studio/backend/routes
Daniel Han e4d1499230
fix(studio): prevent small models from stalling on tool-calling tasks (#4769)
* fix(studio): prevent small models from stalling on tool-calling tasks

Small GGUF models (< 9B params) in "Think, Search, Code" mode would
often describe what they planned to do ("Let me create this dashboard")
and then stop generating without ever calling a tool.

Three changes:

1. Simplify web_tips for small models: remove the "fetch its full content
   by calling web_search with the url parameter" guidance for models < 9B.
   This multi-step instruction causes small models to plan elaborate
   search-then-fetch-then-code sequences they cannot reliably execute.

2. Add "always call tools directly" imperative to the system prompt nudge
   so models act immediately instead of narrating their intentions.

3. Add plan-without-action re-prompt in the agentic loop: when the model
   emits planning text (matching patterns like "let me", "I'll", etc.)
   without calling any tool, inject a nudge asking it to call the tool
   and continue the loop. Capped at 2 re-prompts per request.

Benchmarked with Qwen3.5-4B-GGUF (N=5 trials per variant):
- Baseline: 40% of requests had any tool call
- Combined fix: 100% of requests had at least one tool call

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Daniel Han <danielhanchen@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-04-02 02:11:07 -07:00
..
data_recipe fix: disable OCR in pymupdf4llm PDF extraction (#4659) 2026-03-27 06:53:33 -07:00
.gitkeep root studio folder 2026-02-02 09:13:49 +00:00
__init__.py feat(studio): training history persistence and past runs viewer (#4501) 2026-03-25 00:58:55 -07:00
auth.py studio: fix stale GGUF metadata, update helper model, auth improvements (#4346) 2026-03-17 01:22:08 -07:00
datasets.py fix: subprocess crash during map operation on Windows (#4507) 2026-03-22 05:21:09 -07:00
export.py Final cleanup 2026-03-12 18:28:04 +00:00
inference.py fix(studio): prevent small models from stalling on tool-calling tasks (#4769) 2026-04-02 02:11:07 -07:00
models.py feat: custom scan folders for GGUF model discovery (#4723) 2026-03-31 06:40:31 -07:00
training.py [Studio] multi gpu finetuning/inference via "balanced_low0/sequential" device_map (#4602) 2026-03-30 02:33:15 -07:00
training_history.py feat(studio): training history persistence and past runs viewer (#4501) 2026-03-25 00:58:55 -07:00