Repository navigation
Studio: let chat call Unsloth's own MCP tools - #15631
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Tested this on a branch build with a real GGUF (Qwen3-1.7B, CPU llama.cpp, Windows 11) after merging current main. The chat path works end to end. With Unsloth ticked, the model calls Re-checked at
Smaller:
|
Lets the owner choose which of Unsloth Studio's MCP tools agents can see.
The Agent access (MCP) switch and setup snippet move to the end of
Settings > Agents, under an "Unsloth MCP" heading, with a Tools row
("20 of 23 on") that opens a dialog. The dialog groups the tools (Models,
Generate, Training and export, Data and library, Jobs) with one switch per
tool, one per group, and Turn all on. Settings > API keeps a one-line link
to it.
A tool that is off is left out of tools/list and calls to it are refused.
Saves send only the changed tools (tool_states) and the server merges them,
so two windows toggling different tools both keep their change.
Co-authored-by: Daniel Han <[email protected]>
Adds an "Unsloth" preset to the chat MCP dropdown. Ticking it lets the chat model call Unsloth Studio's own MCP tools in process, with no API key to paste. The chat gets only the tools the owner left on in Settings > Agents, minus the ones that would evict or re-enter the chat that calls them (chat, load_model, unload_model, cancel, start_training, export_model, run_recipe); the tools dialog names those once in a note. Each call runs as the chat's own account with a short-lived internal key that is deleted when the call ends. Host file paths are refused, keyless API callers can't use the row, a chat Stop also stops the image, audio or video job the tool started, and media links open through the session on Desktop and behind a proxy prefix. Co-authored-by: Daniel Han <[email protected]> Co-authored-by: Nilay Yadav <[email protected]>
Chat tool calls get a clear surface and clear failures: - EnsureModel decides whether a request may load the model it names, from a load policy carried by the authenticating key. The chat's per-call key may load beside the chat model, never in its place; otherwise it gets needs_user_load with the Studio page to load it from. Routes no longer import studio_mcp. - Routes name agent-actionable failures in an X-Unsloth-Problem header; studio_mcp/problems.py turns codes into tags and hints for the caller's tools, replacing the English matching in errors.py. - One model identity module for name matching (fixes plan_load and load_model disagreeing on case). - CallerProfile replaces CHAT_DENYLIST: tools declare facts, the profile withholds by them and renders tool text for its own surface. - Read-only MCP tools no longer count as new work in the chat loop, the duplicate-call nudge asks for the answer, chat results drop nulls.
…hen it can't From a live Colab run of the song chat on this branch: - The owner's chat may load a model beside the chat model without "Switch model by request" (off by default). That switch guards API clients; the chat's key can never unload the chat model. A managed account still needs the switch. - needs_user_load names the real reason: Keep multiple models loaded is Off, or the model does not fit under When they fit (set it to Always), or the switch is off for a managed account. It no longer always claims the load "would unload the model serving this chat". - A model that is not on disk gets needs_download, with a download_model hint, instead of needs_user_load. - The hint no longer repeats the instruction the message already gives. - After a needs_user_load result, the chat loop does not re-prompt the model to call tools: telling the user what to do is the answer. - list_models' default source lists downloaded audio.cpp models, which the /v1/models scan skips, so a model download_model just fetched shows up.
…d list_models - A beside-only (chat tools) primary load frees image and video models only, never a kept chat model; a vLLM/SGLang load that would retire kept models refuses with needs_user_load first. - A measured Always refusal no longer tags kind=chat: the kind names the model to unload, so agents were told to unload the chat model even when an image or video model held the GPU. - Revert the audio catalog merge in list_models: /v1/models already lists runnable downloaded audio.cpp models, and the merge listed ones without a runtime and reached the network-backed catalog on every default call. - test_multi_model_always: a padded refusal keeps the X-Unsloth-Problem header.
…d stop re-prompting a chat blocked on the user From a live Colab run: a chat tool loaded the music model beside the chat model (log: "loaded successfully in subprocess"), then the same run failed "No model loaded.". - _run_music_workflow routes to the kept slot, then calls _generate_tts_wav with no model; its _maybe_auto_switch_model(reload-only) re-routed with None and model_slots.route reset routed_slot to the empty primary. A reload-only request now keeps the slot this task already routed to. This also affected the Audio page's music runs with a model kept beside chat. - A music run that names no model uses the one music model kept beside the chat model (several: the caller names one). - tests/test_music_beside_chat.py runs the real route chain up to the orchestrator's generate for a kept model, one loaded on this call, and an omitted model; all three returned "No model loaded." before the fix. - The chat loop's post-tool re-prompt also skips a not_loaded result whose hint asks the user to act.
…odel, and check MCP options against the model that runs - A speak/clone/edit/convert, /v1/audio/speech or separation run that names no model now uses the one model for that workflow kept beside the chat model, as music already did (_route_to_kept_audio_model). Before, it read the primary and answered "No model loaded.". - generate_audio's option check and variations plan read the status of the model that will run: the named one (status?model=), else the one the route picks, including a model kept beside the chat model. Before, they read the chat model's status, so options went unchecked and a sequential music model got one batch request. - test_openai_catalog: reset the media pick cache and resident media status an earlier test can leave, which added a FLUX row in full runs (also on the PR head).
get_job and cancel each carried their own per-kind branches (export, training, load, download, video, recipe, generate_audio). The kinds now live in studio_mcp/job_kinds.py and register with studio_mcp/jobs.py, which gives both tools one lookup, one status shape and one cancel path. The tool modules keep only their MCP signatures and docs. No behavior change: the existing get_job and cancel tests pass unchanged apart from where they patch the moved helpers, and test_mcp_jobs_module.py covers the registry.
0f05c30 to
4a38430
Compare
Merges near-duplicate cases into tables and shared helpers, and drops asserts on incidental wording. Every fix in this PR keeps a regression test; the music scenario now keeps two music models, so it also catches a reload-only TTS step losing its held slot.
…tools # Conflicts: # studio/frontend/scripts/check-bundle-budget.ts
|
Re-checked at Before is main Turning it on: the chat's MCP menu
It works: "Call the studio_status tool" Before: the model can't see the tool. After: the chat calls The three points from my last comment are all still open at this head:
New since then:
Smaller: the body's |
|
Five small commits for #15631, all on LeoBorcherding#655 and each cherry-picks onto your branch as is:
The two frontend reds are main's (same failures on |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…udio generations through batch dedup [skip ci]
…ettings can turn off [skip ci]
…e call returns [skip ci]




Replaces #14349, with the same final code as one commit. It is stacked on #15629, so merge that first. Until then this diff also shows #15629's changes, and only the last commit is new. It includes the fixes Daniel and Nilay made on #14349, and both are credited as co-authors.
Summary
This PR adds an Unsloth preset at the top of the chat MCP dropdown. Ticking it lets the chat model call Unsloth Studio's own MCP tools in process, with no API key to paste and no network listener.
chat,load_model,unload_model,cancel,start_training,export_modelandrun_recipe(CHAT_DENYLISTinmcp_server.py). The tools dialog names those once, in a note under the groups./mcpstill returns 404 while that is off.Safety
Testing
test_mcp_images.pytests fail here and on main.i18n:check:strictpasses, and the settings, MCP and chat-composer tests pass (871).I also ran Unsloth Studio from this branch to check the dropdown and the dialog note.
Studio UI regression check
Base
81dc73ac4vs headfe799ee49. Functional: NO_REGRESSION, UI coverage 83%, 1 visual change(s), 5 text-only change(s). Only steps whose screenshots differ are shown.Note: in this run diffusion_video failed once on head inside the regression harness's own fixture copy (a temp-dir race between the two arms, fixed in the harness), before any request reached Unsloth. A rerun of that journey on both arms at the same head gave 6/6 identical steps; its results are used here.
settings/s06_tab_api: | reproduced on confirm (VISUAL_DIFF)

settings/s10_tab_agentsparallel/stop_trainingcrawl/r_projectscrawl/r_exportcrawl/r_data_recipesChat MCP preset: before and after this layer
BEFORE is #15629's head (
069a35528), AFTER is this PR's head (fe799ee49), so only this layer's change shows; this is not the PR's own merge base.The chat's MCP menu now offers Unsloth first, which answers with Unsloth's own tools in process:
The tools dialog in Settings > Agents ends with the tools a chat never gets ("The chat never gets Load model, Unload model, Plan a load, Chat, Run Data Recipe, Start training, Export model, and Cancel work."):