Route a General Chat question to the profile that fits it

This commit is contained in:
Gmer4Lfe
2026-08-09 00:36:13 -04:00
parent 37784bce6c
commit d9225d06d9
4 changed files with 122 additions and 18 deletions
+27 -2
View File
@@ -247,8 +247,33 @@ incidents, conf lookup, bug filing, code scanning. `chat` holding an empty list
not an oversight: anything added to it stops being general chat and becomes an assistant that
sometimes invents claims about this installation.
`chat` escalates to `varaverk` on its own when a question is genuinely about Varaverk, and
reverts if the index turns out to have nothing — so the loose profile is safe to sit in.
### Routing out of General Chat
`chat` hands a question to whichever profile fits, decided by `vv_ai_route_from_chat()`. Ordered
most specific first, because these overlap on purpose:
| Question | Goes to | Why |
|---|---|---|
| "write me a script that prunes logs" | `code` | asked for something written |
| "why did the daily orch fail" | `troubleshoot` | diagnostic phrasing **and** something here to diagnose |
| "how did the daily orch go" | `varaverk` | about this install, but not a fault |
| "what does arr_sync.sh do" | `varaverk` | names a script, wants documentation |
| "why is the sky blue" | stays `chat` | diagnostic phrasing about nothing here |
`code` is checked first because it is the only intent about a thing that does not exist yet, so
nothing else can claim it — and it is anchored on the verb, which is what keeps "write me a
script" apart from "what does this script do". Escalation adds capability, so a wrong escalation
costs more than a missed one: anything unrecognised stays in `chat`, the profile that cannot
invent claims about this system. The worker reverts to `chat` anyway if retrieval comes back
empty.
The answer opens with one line naming the profile that took it, because the button still shows
the one you picked and an answer arriving under a different contract otherwise reads as the
assistant ignoring you.
Routing is asserted by `Plugin/unraid/Tools/ai_explain_check.sh` against
`ai_explain_fixtures.txt` — every case runs through the worker's `--explain` mode, which stops
where deterministic assembly ends and never calls the model.
This used to live in five places — history depth in the endpoint, capabilities in `include/ai.php`,
label and depth again in JavaScript, a prompt branch in the worker, and a label map on the