fix: ensure JSON output instruction in system prompt override + retry on ValueError

This commit is contained in:
Celes Renata
2026-04-17 17:03:58 +00:00
parent 523d3ea749
commit aa67523acd
+7
View File
@@ -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: