From 01e7ad75788505cbd7bdae730bd086519f95b986 Mon Sep 17 00:00:00 2001 From: chihlasm Date: Sat, 28 Feb 2026 19:55:05 -0500 Subject: [PATCH] feat: update AI system prompt to allow cross-reference loop-back patterns Co-Authored-By: Claude Opus 4.6 --- backend/app/core/ai_chat_service.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/app/core/ai_chat_service.py b/backend/app/core/ai_chat_service.py index 2571ee5b..948f4701 100644 --- a/backend/app/core/ai_chat_service.py +++ b/backend/app/core/ai_chat_service.py @@ -68,10 +68,13 @@ The tree is a recursive JSON structure. Each node has a "type" field: STRUCTURAL RULES: - Root node MUST be type "decision" - Decision nodes contain their children in the "children" array -- Each decision option's next_node_id must reference a child node's id -- Action nodes use next_node_id to chain to the next step (NOT children) +- Each decision option's next_node_id typically references a child node's id, BUT can also reference ANY other node in the tree for loop-back / re-verification patterns +- Action nodes use next_node_id to chain to the next step — this can point to any node in the tree, including ancestors, for loop-backs (e.g., "remediate → re-verify from earlier checkpoint") - Solution nodes are terminal — no next_node_id or children - All IDs must be unique strings (use descriptive slugs like "check-service-status") + +CROSS-REFERENCE / LOOP-BACK PATTERN: +When a troubleshooting path needs to loop back (e.g., after remediation, re-verify from an earlier checkpoint), set next_node_id to the target node's ID. Example: an action node "restart-ssh-service" can set next_node_id to "verify-ssh-connection" (an ancestor decision node) to create a re-verification loop. """ INTERVIEW_PROTOCOL = """