From aa67523acd8d3de27a0fea46c46cb92c5f9a0b62 Mon Sep 17 00:00:00 2001 From: Celes Renata Date: Fri, 17 Apr 2026 17:03:58 +0000 Subject: [PATCH] fix: ensure JSON output instruction in system prompt override + retry on ValueError --- services/extractor/event_classifier.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/extractor/event_classifier.py b/services/extractor/event_classifier.py index 52c8552..382f03c 100644 --- a/services/extractor/event_classifier.py +++ b/services/extractor/event_classifier.py @@ -535,6 +535,13 @@ async def classify_global_event( model_name = resolved.model_name if resolved.system_prompt: prompts["system"] = resolved.system_prompt + # Ensure JSON output instruction is always present regardless + # of custom system prompt (prevents YAML/bullet-point output) + if "json" not in prompts["system"].lower(): + prompts["system"] += ( + "\n\nReturn ONLY a single JSON object. " + "No markdown, no explanation." + ) # Input token limit truncation if resolved is not None and resolved.input_token_limit > 0: