From e03e1fa213650597f8ce75c46f66a00a1437ac0e Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 5 Sep 2026 21:25:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(agent-chat):=20=E7=A1=AE=E8=AE=A4=E6=A1=86?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=B7=A5=E5=85=B7=E5=90=8D+=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=91=98=E8=A6=81=E2=80=94=E2=80=94=E6=97=A7=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E5=8F=AA=E8=AF=BBcommand=E5=AD=97=E6=AE=B5=E8=87=B4ap?= =?UTF-8?q?ply=E7=B1=BB=E5=B7=A5=E5=85=B7=E6=98=BE=E7=A4=BA=E7=A9=BA?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E8=A2=AB=E8=BF=AB=E7=9B=B2=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/api/agent_chat.dspy | 18 ++++++++++++++++-- wwwroot/api/agent_chat_generic.dspy | 15 +++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/wwwroot/api/agent_chat.dspy b/wwwroot/api/agent_chat.dspy index 9a07adf..2ead1c9 100644 --- a/wwwroot/api/agent_chat.dspy +++ b/wwwroot/api/agent_chat.dspy @@ -129,8 +129,22 @@ if action == 'send_message': elif t == 'confirm': _tool = data.get('tool', '') _params = data.get('params', {}) or {} - _cmd = _params.get('command', '') if isinstance(_params, dict) else '' - yield json.dumps({"content": "⚠️ 需要你确认执行命令:`" + str(_cmd)[:120] + "`\n请回复「确认」执行、「全部确认」本会话不再询问,或「取消」放弃。"}, ensure_ascii=False) + '\n' + # 确认框摘要(2026-09-05 修复):旧实现只取 command 字段(run_command 专用), + # 其他工具(apply_llm_config 等参数叫 spec)显示为空命令,用户被迫盲确认。 + # 改为显示工具名 + 关键参数摘要(use_last_extract/overrides/url/model_name 等), + # 大字段(spec/doc_text)只显长度不显内容。 + _brief = [] + if isinstance(_params, dict): + for _k in ('command', 'url', 'model_name', 'use_last_extract', 'overrides', 'task_ref'): + if _k in _params and str(_params.get(_k) or '') != '': + _v = _params.get(_k) + _vs = _v if isinstance(_v, str) else json.dumps(_v, ensure_ascii=False) + _brief.append("%s=%s" % (_k, _vs[:80])) + for _k in ('spec', 'doc_text'): + if _params.get(_k): + _brief.append("%s=<%d字符>" % (_k, len(str(_params.get(_k))))) + _summary = ','.join(_brief) if _brief else '(无参数)' + yield json.dumps({"content": "⚠️ 需要你确认执行工具:**" + str(_tool) + "**\n参数:" + _summary[:300] + "\n请回复「确认」执行、「全部确认」本会话不再询问,或「取消」放弃。"}, ensure_ascii=False) + '\n' elif t == 'error': yield json.dumps({"error": data.get('message', '')}, ensure_ascii=False) + '\n' else: diff --git a/wwwroot/api/agent_chat_generic.dspy b/wwwroot/api/agent_chat_generic.dspy index 3960120..1001585 100644 --- a/wwwroot/api/agent_chat_generic.dspy +++ b/wwwroot/api/agent_chat_generic.dspy @@ -80,8 +80,19 @@ if action == 'send_message': elif t == 'confirm': _tool = data.get('tool', '') _params = data.get('params', {}) or {} - _cmd = _params.get('command', '') if isinstance(_params, dict) else '' - yield json.dumps({"content": "⚠️ 需要你确认执行命令:`" + str(_cmd)[:120] + "`\n请回复「确认」执行、「全部确认」本会话不再询问,或「取消」放弃。"}, ensure_ascii=False) + '\n' + # 确认框摘要(2026-09-05 修复,同 agent_chat.dspy):不再只显示 command 字段 + _brief = [] + if isinstance(_params, dict): + for _k in ('command', 'url', 'model_name', 'use_last_extract', 'overrides', 'task_ref'): + if _k in _params and str(_params.get(_k) or '') != '': + _v = _params.get(_k) + _vs = _v if isinstance(_v, str) else json.dumps(_v, ensure_ascii=False) + _brief.append("%s=%s" % (_k, _vs[:80])) + for _k in ('spec', 'doc_text'): + if _params.get(_k): + _brief.append("%s=<%d字符>" % (_k, len(str(_params.get(_k))))) + _summary = ','.join(_brief) if _brief else '(无参数)' + yield json.dumps({"content": "⚠️ 需要你确认执行工具:**" + str(_tool) + "**\n参数:" + _summary[:300] + "\n请回复「确认」执行、「全部确认」本会话不再询问,或「取消」放弃。"}, ensure_ascii=False) + '\n' elif t == 'error': yield json.dumps({"error": data.get('message', '')}, ensure_ascii=False) + '\n' else: