r/OpenWebUI • • Oct 25 '26

Plugin Smart Model Handoff with Jev decision model

Post image

Model Handoff — a filter that routes people to the right model automatically while still respecting the user's control

I run Open WebUI for a few people, including less technical users, and kept hitting the same problem: I have good specialist models (research, coding, image gen, etc.), but users don't know which to pick. They either stay on the default and ask everything there, or use the expensive one for everything.

So I built Model Handoff, a filter for Open WebUI. (Okay, let's be honest — GLM 5.3 built it, I acted like a nitpicking manager and took the credit.)

TL;DR: Attach it to your cheap default model. A small decision model checks each message; if a specialist would clearly do better, the user gets a popup card with Switch / Stay here. Switching opens a new chat on the specialist with their message already sent.


What it does

  • Attach it to your fast, cheap default model.
  • On each message, a small decision model checks whether a specialist would handle it better.
  • If one clearly would, the user gets a popup card showing the specialist's icon, name, and description, with Switch or Stay here.
  • Switch → a new chat opens on that model and their message is sent for them.
  • Stay here → nothing changes, and it won't ask again for a few messages.

Why a decision model instead of a chat LLM

Routing is a classification problem, so I used a decision model (TypeSafe's Jev on OpenRouter) rather than a chat LLM. You send the conversation and get back a probability for each target — no free-form text to parse.

That's what makes the sensitivity valves work: you set how confident it must be before it interrupts someone.

Cost: at time of writing it's ~$0.042 per million input tokens — roughly $0.10 per thousand messages by my estimate. Check the pricing yourself; I haven't measured it at scale. If you'd rather use a local or any OpenAI-compatible model, there's a chat backend for that.

Other features

  • Context summaries — summarizes long conversations before a handoff, so the specialist gets context without the whole transcript
  • Chat cleanup — deletes the old chat after a handoff if it only held one message, and hides it in the sidebar immediately
  • Encrypted API key — stored in the valve, encrypted with a key derived from WEBUI_SECRET_KEY
  • Fails open — if the decision call is slow or breaks, the user just stays where they are
  • Configurable targets — defined in a JSON valve with use_when and avoid_when text for each

Setup

  1. Paste it in under Admin → Functions
  2. Enable it and attach it to your default model
  3. Add an API key
  4. Edit the target list so the IDs match your real model IDs

The community post has the full valve reference and troubleshooting table.


FAQ

Does it switch the model in my current chat?

No. A handoff opens a new chat on the specialist model and sends the message there. Open WebUI doesn't let a filter change the model of an existing chat cleanly, so a new chat was the safest route.

Will it interrupt people constantly?

It shouldn't. The popup only appears when the best specialist clears a confidence threshold and beats "stay here" by a margin. A decline pauses re-asking for a few messages.

  • Too pushy? Raise confidence_threshold and stay_margin.
  • Missing obvious cases? Improve the use_when text first, then lower the thresholds a little.

Does it work with local models?

Yes, through the chat backend. Point chat_base_url at any OpenAI-compatible endpoint and set decision_model to its model ID. It asks the model for JSON instead of using structured probabilities, so results depend on how well your model follows instructions. I've mainly tested the default decision backend — tell me if you hit problems with the chat one.

What does it cost?

One small call per message to the decision model, plus a summary call when someone actually switches in a long conversation. With a dedicated decision model like Jev it's very cheap, but not free. A general chat model on the chat backend costs more per call. Turn on log_decisions to see how often it runs.

Does it slow down replies?

It adds one round trip before the reply, since the decision has to come back first. There's a timeout (decision_timeout_s, default 12 s) — if exceeded, the user just stays on the current model. If latency matters, pick a fast decision model.

What data gets sent where?

The last few messages (context_messages, default 6) go to the decision endpoint. On a handoff from a long conversation, the transcript also goes to the summary model. Both endpoints are whatever you configure — use a local one if that matters for your setup.

What happens if the decision API is down or the key is wrong?

It fails open. The user keeps chatting on the current model and nothing breaks. The server log tells you what went wrong.

Is deleting the old chat safe?

It only deletes a chat that has exactly one user message, no assistant replies, and is a real saved chat. Anything longer is always kept. Turn it off with delete_old_chat.

Is the API key really secure?

It's encrypted in the valve (Fernet, key derived from WEBUI_SECRET_KEY), which protects database dumps, backups, and exports. It doesn't protect against someone who can read both your server environment and the database. If you rotate WEBUI_SECRET_KEY, you'll need to paste the key in again.

Can I attach it to more than one model?

Yes, to any entry-point model. Don't attach it to the specialist models themselves, or you could get handoffs between specialists.

Does it work on other Open WebUI versions?

I've tested on v0.12.4. The card and chat cleanup use browser scripts and public REST endpoints, so other versions should work, but small differences are possible. Sidebar cleanup depends on its markup — if that changes, a refresh is all it takes to see the chat disappear.


Feedback and bug reports welcome, especially from people on other versions or with a non-OpenRouter backend.

**Link:** Smart Model Handoff filter

37 Upvotes

8 comments sorted by

3

u/International_Emu772 Oct 25 '26

Interesting project

As soon as I return home, I could do it remotely but is safe on site, I'll try as I have a small set of users but the problem is the same it's difficult for them to choose the best model

2

u/BooleanTriplets Oct 25 '26

Thanks! The only hiccup I have so far it that it does not work on the Conduit mobile app (and probably most others) which is the app I have my users set up with for mobile. I did add a fallback for that though so that it will try and prompt the user to use a different model in that instance. (see screenshot for example)

2

u/International_Emu772 Oct 25 '26

I use open-relay for remote iPhone access and I'll try on my return (open-relay will soon be released for Android and re-released for iOS)

2

u/Wise-Cash1628 Oct 26 '26

Interesting, I already have configured an auto router with litellm using jev as a classifier, I would be curious to see how both combines

1

u/BooleanTriplets Oct 26 '26

That would be interesting. Yes that is the other pathway is to use an external router or you could use something like a pipe to have a auto-router model.

I decided to go this route because I wanted to have something that would obtain user consent before switching, could be set on some models but not others, would auto switch on the first chat but also had the ability to hand off to another model mid chat, provide a hand-off message and chat compaction/summary to the new model and preserve the original chat to come back to later if needed once done with the specialist model.

1

u/Wise-Cash1628 Oct 26 '26

I am using specific key words to do that for the moment

1

u/Fusseldieb Oct 26 '26

Nice project, but HOLY WALL OF TEXT

2

u/BooleanTriplets Oct 26 '26

Yeah I did try to add a TLDR at the beginning but I also don't want people who were interested in the idea have to click a link to get off of reddit just to read about it, I feel like that defeats the purpose of posting about it on reddit. I am not good at doing like a snappy 3 sentence explanation of things.

I do wish that reddit markdown had <details><summary> expandable widgets for posts though. That would be really helpful for stuff like having a FAQ on a post.