From 198532e280e62a6d448f8bad6e8bd5bc2c2a56a5 Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Sun, 2 Aug 2026 17:45:41 -0400 Subject: [PATCH] Send all health checks as live state, not only the failing ones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Asked what was wrong, it answered "AI_ENABLED=false" — read from the conf template, which records the shipped default, while the live value was true. Passing checks are what tell the model the current value of a setting; without them a documented default fills the silence. The prompt now states explicitly that live state overrides any documented default. --- Plugin/unraid/Tools/ai_chat_worker.php | 35 +++++++++++++++++--------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/Plugin/unraid/Tools/ai_chat_worker.php b/Plugin/unraid/Tools/ai_chat_worker.php index bae3f4b..00fcce5 100644 --- a/Plugin/unraid/Tools/ai_chat_worker.php +++ b/Plugin/unraid/Tools/ai_chat_worker.php @@ -135,15 +135,20 @@ $diagnostic = (bool)preg_match( $diagBlock = ''; if ($diagnostic) { - $bad = array_filter(vv_ai_health(), fn($c) => in_array($c['state'], ['bad', 'warn'], true)); - if ($bad) { - $diagBlock .= "CURRENT CONFIGURATION PROBLEMS\n"; - foreach ($bad as $c) { - $diagBlock .= '- [' . strtoupper($c['state']) . '] ' . $c['label'] . ': ' . $c['detail'] - . ($c['fix'] !== '' ? ' — ' . $c['fix'] : '') . "\n"; - } - $diagBlock .= "\n"; + // Every check, not only the failing ones. Passing checks are what tell the model the + // current value of a setting — without them it has no live signal for anything healthy, + // and a documented default fills the gap. That produced a confidently wrong answer: + // asked what was wrong, it reported "AI_ENABLED=false" read from the conf *template* + // while the live value was true. Documentation records defaults; only this block records + // what is actually set. + $diagBlock .= "LIVE SYSTEM STATE (authoritative — measured just now)\n"; + foreach (vv_ai_health() as $c) { + $mark = ['ok' => 'OK', 'warn' => 'WARNING', 'bad' => 'PROBLEM'][$c['state']] ?? '?'; + $diagBlock .= '- [' . $mark . '] ' . $c['label'] . ': ' . $c['detail'] + . ($c['state'] !== 'ok' && $c['fix'] !== '' ? ' — FIX: ' . $c['fix'] : '') . "\n"; } + $diagBlock .= "\n"; + $logs = vv_ai_recent_logs(40); if ($logs) { $diagBlock .= "RECENT WARNINGS AND ERRORS (newest last)\n" . implode("\n", $logs) . "\n\n"; @@ -159,10 +164,16 @@ $system = "You are Varaverk's documentation assistant. Varaverk is this user's p if ($diagBlock !== '') { $system .= "This is a diagnostic question, so live system state is included alongside the " - . "documentation. Use the passages to explain how the thing is supposed to work, " - . "and the live state to say what is actually wrong. When a configuration problem " - . "is listed, name the specific setting and the file it lives in. Log lines are " - . "evidence, not citations — cite only the numbered passages.\n\n" + . "documentation.\n\n" + . "CRITICAL: where the live state contradicts anything in the passages, the live " + . "state is correct. The passages include conf templates and design notes that " + . "record DEFAULT values, not this system's current ones — a template showing " + . "AI_ENABLED=false says what a fresh install ships with, never what is set here. " + . "Never report a documented default as the current value.\n\n" + . "Use the passages to explain how a thing is supposed to work, and the live state " + . "to say what is actually happening. When a problem is listed, name the specific " + . "setting and the file it lives in. Log lines are evidence, not citations — cite " + . "only the numbered passages.\n\n" . $diagBlock; }