fix: devops直接用message_text作命令,去掉前缀

This commit is contained in:
yumoqing 2026-08-05 18:03:16 +08:00
parent 1d22da86ac
commit 746b372a6e

View File

@ -876,12 +876,12 @@ if action == 'send_message':
else:
agent_reply = f"❌ 导入失败:{msg}"
elif intent_type == 'devops':
description = intent.get('description', '') or message_text
# 去掉中文前缀("执行命令:"、"运行:"等)
# LLM 分类器的 description 可能是自然语言,直接用用户原始消息作为命令
cmd = message_text.strip()
import re
description = re.sub(r'^(执行命令[:]|运行[:])', '', description.strip())
cmd = re.sub(r'^(执行命令[:]|运行[:]|帮我\s*)', '', cmd).strip()
workdir = ctx.get('workspace_dir', '') or '/d/pipeline/workspaces'
result = await shell_exec(description, workdir=workdir)
result = await shell_exec(cmd, workdir=workdir)
if result['rc'] == 0:
out = result['stdout'].strip()
agent_reply = f"执行成功。{'输出:' + out[:500] if out else '(无输出)'}"