diff --git a/wwwroot/api/cockpit_chat.dspy b/wwwroot/api/cockpit_chat.dspy index 295d428..7426b0e 100644 --- a/wwwroot/api/cockpit_chat.dspy +++ b/wwwroot/api/cockpit_chat.dspy @@ -164,6 +164,8 @@ def _parse(raw): # Strip any {"action":"tool_call"...} JSON fragments from reply text import re as _re2 clean = _re2.sub(r'\s*\{[^}]*"action"\s*:\s*"tool_call"[^}]*\}\s*', ' ', raw).strip() + # Remove stray trailing braces from malformed JSON attempts + clean = clean.rstrip().rstrip('}').strip() return {"action":"reply","message":clean or raw} def _w_text(t): return {"widgettype":"Text","options":{"text":t,"css":"agent-text","halign":"left"}}