From 552f4be1ad681263cde5cb1513aab62aaac80e66 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Sat, 14 Nov 2026 13:27:47 -0600 Subject: [PATCH] Pass Holmes diagnostic evidence as context file --- docs/doctor-overview.md | 2 ++ scripts/doctor-focus | 4 +++- tests/jeannie/test_doctor_focus.py | 10 ++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/doctor-overview.md b/docs/doctor-overview.md index cc728b1..aa5ac9d 100644 --- a/docs/doctor-overview.md +++ b/docs/doctor-overview.md @@ -90,6 +90,8 @@ The focused Kubernetes repair prompt includes the repository's the evidence needed before considering a normal pod recreation after a storage reconnect. This is guidance for Holmes, not enforcement of its actions; its host-level Bash permissions remain unchanged. +Detailed evidence and the skill are passed as a Holmes context file so mount +paths containing brackets are not interpreted as terminal markup. If Holmes records no tool calls, Doctor marks the investigation incomplete even when the model prints what looks like a tool request as ordinary text. A tool call record alone does not prove that a repair was made or succeeded. diff --git a/scripts/doctor-focus b/scripts/doctor-focus index 7c63a3c..38a2973 100644 --- a/scripts/doctor-focus +++ b/scripts/doctor-focus @@ -157,7 +157,8 @@ doctor_focus_holmes_fix() { cat "${REPORT_UI_ROWS_FILE}" printf '\nHomelab skill: use only when its stated conditions match the observed evidence.\n' cat "${REPO_ROOT}/infra/ai-stack/holmes-skills/k3s-stale-volume/SKILL.md" - } >"${artifact}/holmes-prompt.txt" + } >"${artifact}/holmes-context.txt" + printf 'Investigate and repair Kubernetes application %s using the supplied context file. Follow its procedure and report the outcome.\n' "${item}" >"${artifact}/holmes-prompt.txt" record_change_journal "doctor-holmes-k8s-repair" "${item}" echo "Holmes is authorized to execute commands to repair ${item}; its Bash tool has host-level access." if ! timeout "${LAB_HOLMES_REPAIR_TIMEOUT_SECONDS:-900}" env KUBECONFIG="${KUBECONFIG_PATH}" \ @@ -166,6 +167,7 @@ doctor_focus_holmes_fix() { OPENAI_API_BASE="${OPENAI_BASE_URL:-http://127.0.0.1:20128/v1}" OPENAI_API_KEY="${key}" \ python3 "${REPO_ROOT}/scripts/doctor-holmes-interactive.py" "${artifact}/conversation.json" -- \ "${bin}" ask --config "${config}" --prompt-file "${artifact}/holmes-prompt.txt" \ + --file "${artifact}/holmes-context.txt" \ --api-key "${key}" --model "${model}" --fast-model "${fast}" \ --max-steps "${LAB_HOLMES_REPAIR_MAX_STEPS:-30}" --fast-mode --interactive --bash-always-allow --json-output-file "${artifact}/conversation.json" \ >"${artifact}/holmes-output.txt" 2>"${artifact}/holmes-error.txt"; then diff --git a/tests/jeannie/test_doctor_focus.py b/tests/jeannie/test_doctor_focus.py index 7ee1875..1e85dc3 100644 --- a/tests/jeannie/test_doctor_focus.py +++ b/tests/jeannie/test_doctor_focus.py @@ -33,7 +33,7 @@ class DoctorFocusTests(unittest.TestCase): "echo 'attempted repair'\nread -r line\n[ \"$line\" = /exit ]\n") binary.chmod(0o755) rows = root / "rows" - rows.write_text("warn\tKubernetes apps\tn8n\tUnavailable\n") + rows.write_text("warn\tKubernetes apps\tn8n\tUnavailable\t/dev/sda1[/openebs/volume]\n") env = os.environ.copy() env.update(PATH=f"{root}:{env.get('PATH', '')}", REPO_ROOT=str(ROOT), HOME=str(root), REPORT_UI_ROWS_FILE=str(rows), KUBECONFIG_PATH="/tmp/test-kubeconfig", @@ -49,9 +49,11 @@ doctor_focus_holmes_fix n8n''' self.assertIn("Independent post-repair Argo CD check: healthy", result.stdout) artifact = next((root / "artifacts").glob("repair.*")) self.assertIn("application n8n", (artifact / "holmes-prompt.txt").read_text()) - self.assertIn("five whys", (artifact / "holmes-prompt.txt").read_text()) - self.assertIn("K3s stale local-volume mount", (artifact / "holmes-prompt.txt").read_text()) - self.assertIn("Distinguish I/O errors from permissions", (artifact / "holmes-prompt.txt").read_text()) + self.assertIn("five whys", (artifact / "holmes-context.txt").read_text()) + self.assertIn("K3s stale local-volume mount", (artifact / "holmes-context.txt").read_text()) + self.assertIn("Distinguish I/O errors from permissions", (artifact / "holmes-context.txt").read_text()) + self.assertIn("/dev/sda1[/openebs/volume]", (artifact / "holmes-context.txt").read_text()) + self.assertNotIn("[/openebs/volume]", (artifact / "holmes-prompt.txt").read_text()) self.assertIn("does not prove end-to-end", (artifact / "report.txt").read_text()) def test_holmes_repair_rejects_text_only_tool_request(self):