From 13f2e1405039459b7736d0c34b5839adaad7da67 Mon Sep 17 00:00:00 2001 From: Chaim Date: Thu, 23 Apr 2026 19:53:06 +0000 Subject: [PATCH] fix(kb): pin /kb/ask prompt to Israeli National Insurance context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The KB UI's ask mode was hijacking into generic Israeli law. Asked "מתי אפשר לבקש דיון מחדש לפי תקנה 37?" Shira answered with תקנה 37 of תקנות סדר הדין האזרחי (civil procedure) instead of תקנה 37 to the National Insurance regulations — even though search_insurance_kb has the correct source. Append a short context block to the system prompt telling Shira that every question from the KB UI is about ביטוח לאומי, that she must call search_insurance_kb first and cite section_ref, and that she must say so explicitly if no KB section matches. Refs Task Master #2 Co-Authored-By: Claude Opus 4.7 (1M context) --- api/routes/kb_public.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/api/routes/kb_public.py b/api/routes/kb_public.py index 05829c6..f62ecbb 100644 --- a/api/routes/kb_public.py +++ b/api/routes/kb_public.py @@ -145,6 +145,17 @@ async def ask(body: AskRequest, request: Request): user_profile="", available_skills=list_skills(), ) + # Pin the question to the insurance KB context so generic-law answers + # (e.g. "תקנה 37 לתקנות סדר הדין האזרחי") don't hijack the response. + system_prompt += ( + "\n\nContext: The user is asking from the Knowledge Base UI of the " + "Israeli National Insurance firm. Every question should be answered " + "from the KB of חוק/תקנות/חוזרי הביטוח הלאומי. Before answering, " + "call search_insurance_kb to retrieve the relevant sections, and " + "cite them explicitly with section_ref (ס' N, תקנה N, or חוזר N/YYYY). " + "Never answer from generic legal training if the KB has a matching " + "section — if no KB section matches, say so explicitly." + ) messages: list[dict] = [] for m in (body.conversation_history or []):