Skip to content

Studio: Open WebUI llama.cpp residency and explicit load/unload (#10610) - #10693

Merged
danielhanchen merged 16 commits into
unslothai:mainfrom
debojyoti-dev:feature/10610-open-webui-model-residency-load-unload
Oct 13, 2026
Merged

danielhanchen merged 16 commits into
unslothai:mainfrom
debojyoti-dev:feature/10610-open-webui-model-residency-load-unload

Conversation

@debojyoti-dev

@debojyoti-dev debojyoti-dev commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Open WebUI's llama.cpp provider needs two things from Studio. This PR serves both.

  • Residency. Every GET /v1/models row, including the quant-pin rows and GET /v1/models/{id}, now carries status.value (loaded / unloaded) next to loaded. Open WebUI calls a row without status loaded, so a downloaded but nonresident model no longer shows as loaded.
  • Model management outside /v1. Open WebUI strips /v1 for these calls.
    • GET /models lists the chat rows of the caller's own /v1/models. Image, video and speech rows are left out because they load through their own engines.
    • POST /models/load with {"model": "<id>"} loads a listed row. It uses the on-disk copy and saved launch settings that auto-switch would use, and the row keeps its listed id as the advertised id.
    • POST /models/unload with {"model": "<id>"} stops the resident or in-flight load that the row names: by path, advertised alias, Ollama tag or quant. An idle row, an unrelated load, or another account's hidden resident is a no-op.
    • Both go through load_model_gated / _unload_model_impl with Studio's GPU-busy 409 and tunnel padding. They answer {"success": true, "model": "<listed id>"}, never a host path.
    • A <id>:<quant> pin must be quant-shaped and on disk, otherwise the route returns 404. Unknown ids return 404 and no credential returns 401. GET /models is in the keyless inference grant like GET /v1/models; load and unload stay credentialed.
  • Download, delete and GET /models/sse stay JSON 404, as do the wrong methods on the new paths.

Fixes #10610

Testing

  • studio/backend/tests/test_llama_compat_routes.py, test_openai_catalog.py, test_openai_models_path_leak.py, test_keyless_api_access_adversarial.py, test_warm_window_review_fixes.py: 316 passed. The management tests fail against main and against each earlier head they guard.
  • Live on a GPU with a real Studio install and llama-server:
    • an HF-cache GGUF and a scan-folder GGUF (MyLocalQwen) each load and unload through /models/load and /models/unload;
    • /v1/models flips loaded and status.value with no duplicate rows;
    • an unload sent while a load is in flight cancels it;
    • an image row returns 404.
  • Open WebUI's own get_provider_model_loaded_state (pinned at 0a7c158) reads a nonresident row as unloaded with status, and as loaded without it.
  • Staging CI is green.

…othai#10610)

Publish status.value alongside loaded so Open WebUI's llama.cpp provider
does not treat nonresident catalog rows as loaded, and serve authenticated
GET /models plus POST /models/load|/unload outside /v1.

Co-authored-by: Cursor <[email protected]>
@danielhanchen

Copy link
Copy Markdown
Member

Confirmed main still denies /models, /models/load and /models/unload in studio/backend/routes/llama_compat.py, and that the catalog publishes no status field, so this is a real gap for Open WebUI's llama.cpp provider. Will get this reviewed.

@debojyoti-dev

Copy link
Copy Markdown
Contributor Author

Confirmed main still denies /models, /models/load and /models/unload in studio/backend/routes/llama_compat.py, and that the catalog publishes no status field, so this is a real gap for Open WebUI's llama.cpp provider. Will get this reviewed.

Thanks! @danielhanchen

@danielhanchen danielhanchen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @debojyoti-dev. I merged main (which had since added the llama-server passthrough routes and per-account isolation) and pushed e0f8292 on top of your commits:

  • /models/load and /models/unload now call Studio's own /api/inference/load and /api/inference/unload handlers, so they get the same GPU-busy 409s, managed-account checks and tunnel padding instead of a separate error path.
  • The model id must be in the caller's own /v1/models catalog (an exact id or <id>:<quant>). For a load, the on-disk GGUF that auto-switch would pick is still preferred.
  • The served methods go through the existing served-route set that the passthrough routes use, so the separate denial table and the is_engine_probe_path special case are gone. POST/DELETE /models, GET /models/sse and the wrong methods on load/unload still return a JSON 404.
  • One status.value stamp is applied to every catalog row and to the single-model lookup.
  • The 506-line test module is now about 120 lines of tests in test_llama_compat_routes.py. Against main's llama_compat.py they fail (9 failed), and on this branch they pass: 198 passed across the compat, catalog, path-leak and keyless suites.

I also checked this against the real Studio app with Open WebUI's actual get_provider_model_loaded_state. A nonresident row now reads as unloaded (it read as loaded without status), and GET /models is 401 without a credential. Download, delete and SSE are separate Open WebUI actions, so a 404 there only fails that one action.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T22:32:28.821523Z 48d771a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 12, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 48d771ac5d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@danielhanchen
danielhanchen merged commit b865e89 into unslothai:main Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Open WebUI compatibility: model residency and explicit load/unload

2 participants