diff --git a/wwwroot/api/cockpit_chat.dspy b/wwwroot/api/cockpit_chat.dspy index 8b10302..0c13ca3 100644 --- a/wwwroot/api/cockpit_chat.dspy +++ b/wwwroot/api/cockpit_chat.dspy @@ -154,7 +154,10 @@ def _parse(raw): d = json.loads(raw) if isinstance(d,dict) and 'action' in d: return d except: pass - return {"action":"reply","message":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() + return {"action":"reply","message":clean or raw} def _w_text(t): return {"widgettype":"Text","options":{"text":t,"css":"agent-text","halign":"left"}} def _w_card(title, body, kind="success"):