Route a General Chat question to the profile that fits it
This commit is contained in:
@@ -151,11 +151,19 @@ $profileAsked = $profile;
|
||||
// returns it to where it started rather than choosing a profile for it.
|
||||
//
|
||||
// The trigger is the same detector the deterministic backstop uses, so the two cannot disagree.
|
||||
// The target is chosen by vv_ai_route_from_chat(), not fixed at varaverk. General Chat used to
|
||||
// have exactly one place to escalate to, which meant "why did the daily orch fail" and "write me
|
||||
// a script that prunes logs" both arrived at the documentation assistant — the first wanting a
|
||||
// log it is not given by default, the second wanting code from a profile whose contract is to
|
||||
// answer only from passages. Both were answered adequately and neither was answered well.
|
||||
$escalated = false;
|
||||
if ($profile === 'chat' && vv_ai_chat_needs_varaverk($question)) {
|
||||
$profile = 'varaverk';
|
||||
$escalated = true;
|
||||
wlog('handoff chat -> varaverk: ' . mb_substr($question, 0, 80));
|
||||
if ($profile === 'chat') {
|
||||
$to = vv_ai_route_from_chat($question);
|
||||
if ($to !== '' && $to !== $profile) {
|
||||
$profile = $to;
|
||||
$escalated = true;
|
||||
wlog('handoff chat -> ' . $to . ': ' . mb_substr($question, 0, 80));
|
||||
}
|
||||
}
|
||||
|
||||
// Every "is this profile allowed X" question in this file goes through here. Bound by reference
|
||||
@@ -279,11 +287,10 @@ $rec = ($runTarget !== '' && vv_ai_scope_ok($runTarget))
|
||||
// no record at all — is not clean and is treated as worth investigating.
|
||||
$runClean = $rec['ok'] && $rec['status'] === 'ok' && $rec['exit'] === 0 && $rec['end'] !== null;
|
||||
|
||||
$kwDiagnostic = (bool)preg_match(
|
||||
'/\b(why|fail(ed|ing|ure)?|error|broken?|not work|isn.t work|wrong|stuck|hang|'
|
||||
. 'never runs?|didn.t|won.t|debug|troubleshoot|diagnos)/i',
|
||||
$question
|
||||
);
|
||||
// The same detector the router uses to send a question here in the first place. Two copies of
|
||||
// this regex would mean a question could be routed to Troubleshoot as diagnostic and then have
|
||||
// live state withheld from it as not-diagnostic, which is the worst of both.
|
||||
$kwDiagnostic = vv_ai_is_diagnostic($question);
|
||||
|
||||
// Permission first, need second: the capability decides whether live state may be attached at
|
||||
// all, and only then does the phrasing decide whether this particular question warrants it.
|
||||
@@ -566,15 +573,21 @@ if ($profile === 'chat') {
|
||||
// itself: they picked a profile, the profile button in the tab still shows the one they picked,
|
||||
// and an answer that quietly arrives under a different contract — with citations and a refusal
|
||||
// rule they did not ask for — reads as the assistant ignoring them. One line, at the top.
|
||||
// Names the profile that actually took it. The line used to say "the Varaverk Assistant"
|
||||
// regardless, which was true while that was the only place a question could go and became a lie
|
||||
// the moment the router could hand one to Troubleshoot or Code Sketcher.
|
||||
if ($escalated) {
|
||||
$system .= "HOW THIS QUESTION REACHED YOU\n"
|
||||
. "The operator asked in General Chat, which is not shown Varaverk's documentation. "
|
||||
. "Their message named something specific to this installation, so it was handed to "
|
||||
. "you, and you do have the material. Open with one short line saying so — something "
|
||||
. "like \"General Chat can't see your docs, so I've picked this up as the Varaverk "
|
||||
. "Assistant\" — then answer the question normally. One line: do not apologise for "
|
||||
. "the switch, do not explain how the profiles work, and do not suggest they switch "
|
||||
. "profile themselves. It has already happened.\n\n";
|
||||
. "The operator asked in General Chat, which is not shown Varaverk's documentation "
|
||||
. "and holds no tools. Their message was " . match ($profile) {
|
||||
'troubleshoot' => 'a question about something going wrong',
|
||||
'code' => 'a request for a script to be written',
|
||||
default => 'about something specific to this installation',
|
||||
} . ", so it was handed to you, and you do have what it needs. Open with one short "
|
||||
. "line saying so — something like \"General Chat can't do that, so I've picked this "
|
||||
. "up as " . vv_ai_profile_label($profile) . "\" — then answer the question normally. "
|
||||
. "One line: do not apologise for the switch, do not explain how the profiles work, "
|
||||
. "and do not suggest they switch profile themselves. It has already happened.\n\n";
|
||||
}
|
||||
|
||||
// A run-outcome question arrives with the run attached, and the assistant's standing contract —
|
||||
|
||||
Reference in New Issue
Block a user