Skip to content

internal/server: support Open WebUI model unload - #924

Open
penica wants to merge 2 commits into
mostlygeek:mainfrom
penica:fix/open-webui-unload-compat
Open

internal/server: support Open WebUI model unload#924
penica wants to merge 2 commits into
mostlygeek:mainfrom
penica:fix/open-webui-unload-compat

Conversation

@penica

@penica penica commented Jul 12, 2026

Copy link
Copy Markdown

Add the llama.cpp-compatible named unload endpoint so Open WebUI can unload configured models and aliases without using the management API.

  • validate named unload requests
  • resolve aliases to canonical local models
  • preserve management unload behavior with regression coverage

Add the llama.cpp-compatible named unload endpoint so Open WebUI can unload configured models and aliases without using the management API.
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 14f6bfd6-2008-47c7-bded-449b171e4695

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 12, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds Open WebUI support for unloading a named model. The main changes are:

  • New authenticated POST /models/unload route.
  • Shared unload helper for configured models and aliases.
  • JSON request validation for named unloads.
  • Tests for alias unloads, invalid requests, and existing unload behavior.

Confidence Score: 4/5

The changed flow looks mergeable after a small cleanup to model-name handling.

  • The new route is authenticated and does not collide with existing unload or model routes.
  • Alias unloads use the shared config lookup path.
  • The JSON endpoint trims names before exact config lookup, which can make literal whitespace-bearing names unreachable.

internal/server/apigroup.go

Important Files Changed

Filename Overview
internal/server/apigroup.go Adds the shared unload helper and the Open WebUI JSON unload handler.
internal/server/server.go Registers the new POST /models/unload endpoint on the API middleware chain.
internal/server/server_test.go Extends the test router to record unload targets for assertions.
internal/server/unload_test.go Adds tests for canonical unloads, alias unloads, invalid requests, and existing route behavior.

Reviews (1): Last reviewed commit: "internal/server: support Open WebUI mode..." | Re-trigger Greptile

requested := strings.TrimSpace(body.Model)
if requested == "" {
shared.SendResponse(w, r, http.StatusBadRequest, "model is required")
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Whitespace Trims Configured Names

When a configured model or alias intentionally begins or ends with whitespace, this endpoint changes the requested name before RealModelName performs its exact lookup. That makes a valid configured model unreachable through POST /models/unload, returning model not found while the same literal name can still be represented in JSON.

Context Used: AGENTS.md (source)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 4d3f4ba. The handler now trims only to reject whitespace-only requests and passes the original model string to canonical lookup. Added regression coverage for an alias with surrounding whitespace. Focused tests and make test-all pass.

Keep exact configured model IDs and aliases during Open WebUI unload lookup while still rejecting whitespace-only requests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant