From cb5846c39e64a3a7cccf845295b572782b1c478c Mon Sep 17 00:00:00 2001 From: ymq Date: Mon, 10 Aug 2026 00:08:40 +0800 Subject: [PATCH] fix: strip tool_call JSON fragments from reply text before display and history --- wwwroot/api/cockpit_chat.dspy | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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"):