unsloth/studio/backend/routes
Daniel Han 09ca2a1777 Studio: retry agentic loop on validation failure
Adds a pre-dispatch validation pass inside both agentic tool loops
(generate_chat_completion_with_tools in core/inference/llama_cpp.py and
run_safetensors_tool_loop in core/inference/safetensors_agentic.py).

The pass catches two failure modes between parser and dispatch:

* Unknown tool name (not in the request's tools[] array).
* Arguments that cannot decode to a JSON object when auto_heal is off.

On a caught call the loop appends a corrective tool-result message
tied to the hallucinated tool_call_id (not a fabricated id, so the
OpenAI chat template stays valid) and re-enters the model. When the
call has no usable id we fall back to a user-role correction since
tool-role messages require a matching prior call id.

The retry pass is bounded by max_validation_retries (default 2, new
ChatCompletionRequest field, threaded through the route layer). On
budget exhaustion the call falls through to the existing per-tool
error path so today's behavior is preserved.

When auto_heal_tool_calls is on the heal path still runs in the
dispatch loop unchanged; F3 only catches the strict-shape failures
the coercer cannot fix.
2026-05-22 14:42:19 +00:00
..
data_recipe Studio: fix 7 failing studio_unit_tests on main (#5216) 2026-04-28 22:43:44 -07:00
.gitkeep root studio folder 2026-02-02 09:13:49 +00:00
__init__.py Studio: persist chat history in backend storage (#5272) 2026-05-22 06:18:05 -07:00
auth.py studio: proxy-aware login rate-limit; allow google favicons in CSP (#5489) 2026-05-18 00:02:15 -07:00
chat_history.py Studio: persist chat history in backend storage (#5272) 2026-05-22 06:18:05 -07:00
datasets.py studio: show HF model download progress in training start overlay (#4894) 2026-04-14 08:54:01 -07:00
export.py studio: security and hardening pass (auth rate-limit, sandbox, path containment, schema validation, headers) (#5375) 2026-05-13 06:12:18 -07:00
inference.py Studio: retry agentic loop on validation failure 2026-05-22 14:42:19 +00:00
models.py Fix /recommended-folders 500 on unreadable model directories (Python 3.12+) (#5523) 2026-05-18 00:16:14 +04:00
providers.py Studio: per-session cost calculator + /api/providers/pricing endpoint (#5690) 2026-05-22 06:03:43 -07:00
training.py studio: drop unused max_grad_value schema + route plumbing (#5424) 2026-05-14 05:43:58 -07:00
training_history.py Studio: Dark theme refactor, right sidebar redesign, and chat UI polish (#5150) 2026-05-07 14:33:31 +04:00