unsloth/studio/backend/routes
Daniel Han 4f9986ecb9
fix(studio): improve tool-calling re-prompt for small models (#4783)
Small GGUF models (<9B) frequently generate full code or lengthy
explanations instead of calling tools, bypassing the existing
plan-without-action re-prompt mechanism. Three issues:

1. _REPROMPT_MAX_CHARS=500 was too low -- models that output full
   HTML/code responses (often 1000+ chars) never triggered the
   re-prompt at all, since it only fires on short responses.

2. _MAX_REPROMPTS=1 gave the model only one chance to comply.
   Small models often need 2-3 nudges before switching from
   text generation to tool calling.

3. The re-prompt text ("Please use the available tools...") was
   too polite for small models to follow reliably.

4. Tool-calling detection missed chat templates using Jinja
   whitespace-trimming syntax ({%- if tools -%}) since only
   ({%- if tools %}) and ({% if tools %}) were checked.

Changes:
- Raise _REPROMPT_MAX_CHARS from 500 to 2000 so longer responses
  (code blocks, multi-paragraph plans) still trigger re-prompts
- Raise _MAX_REPROMPTS from 1 to 3 for more retry budget
- Use direct, imperative re-prompt language that small models
  follow more reliably ("STOP. You MUST call a tool NOW.")
- Strengthen the system prompt tool nudge to explicitly forbid
  outputting code blocks (redirect to the python tool instead)
- Add Jinja whitespace-trimmed variants to the tool_markers
  list so all template styles are detected correctly
2026-04-02 08:59:02 -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): improve tool-calling re-prompt for small models (#4783) 2026-04-02 08:59:02 -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