feat: add start_agent + agent_status intent handlers

This commit is contained in:
yumoqing 2026-08-02 16:00:16 +08:00
parent 0d0c8299e8
commit 4ba5d84cf7

View File

@ -225,6 +225,8 @@ INTENT_PROMPT = """你是一个开发产线意图分类器。分析用户输入
- new_iteration: 在当前项目下创建新迭代
- new_task: 提交开发任务(需关联项目/迭代)
- add_bug: 报告Bug
- start_agent: 启动Agent自动执行任务
- agent_status: 查看Agent状态和交付件
- query: 查询当前状态
- chat: 开发相关的一般对话
- out_of_scope: 完全无关软件开发
@ -389,6 +391,40 @@ if action == 'send_message':
agent_reply = '\n'.join(ctx_info) + '\n\n请描述具体想查询什么任务列表、Bug列表等'
else:
agent_reply = "当前未选择项目。请先「创建XXX项目」或「切换到XXX项目」。"
elif intent_type == 'start_agent':
pid = ctx['project_id']
if not pid:
agent_reply = "请先指定项目。「创建XXX项目」或「切换到XXX项目」"
else:
try:
result = await run_agent_loop(pid, 'developer', user_model_id or None)
status = result[0] if result else {}
agent_reply = f"✅ Agent已执行{status.get('status','?')} / {status.get('message',status.get('task_id','?'))}"
except Exception as e:
agent_reply = f"Agent启动失败{str(e)[:200]}"
elif intent_type == 'agent_status':
pid = ctx['project_id']
if not pid:
agent_reply = "当前未选择项目。"
else:
async with DBPools().sqlorContext(dbname) as sor2:
# Agent status
arecs = await sor2.sqlExe(
"SELECT role_name, status, model_name FROM pipeline_project_agents WHERE project_id=${pid}$",
{"pid": pid})
# Recent deliverables
drecs = await sor2.sqlExe(
"SELECT title, deliverable_type, quality_score, review_status, created_at "
"FROM pipeline_deliverables WHERE project_id=${pid}$ ORDER BY created_at DESC LIMIT 3",
{"pid": pid})
lines = [f"📁 项目:{ctx['project_name']}"]
for a in arecs:
lines.append(f"🤖 {a.role_name}{a.status}")
if drecs:
lines.append("📦 最近交付:")
for d in drecs:
lines.append(f" · {d.title} [{d.review_status}] {d.quality_score}分")
agent_reply = '\n'.join(lines) if len(lines) > 1 else "暂无Agent活动"
else:
# chat: general conversation
messages = await _build_context(sor, iteration_id or ctx['iteration_id'], '',