diff --git a/wwwroot/api/cockpit_chat.dspy b/wwwroot/api/cockpit_chat.dspy index 5367cd4..ec9b926 100644 --- a/wwwroot/api/cockpit_chat.dspy +++ b/wwwroot/api/cockpit_chat.dspy @@ -396,10 +396,13 @@ async def _exec_tool(sor, tool, params, ctx, uid, org_id): ans = p.get('answer','') if not qid: return 'FAIL: 需要问题ID' if not ans: return 'FAIL: 需要回答内容' - qs = await sor.sqlExe("SELECT id,status FROM pipeline_agent_questions WHERE id=${q}$",{"q":qid}) + qs = await sor.sqlExe("SELECT id,task_id FROM pipeline_agent_questions WHERE id=${q}$",{"q":qid}) if not qs: return 'FAIL: 问题不存在' - await sor.sqlExe("UPDATE pipeline_agent_questions SET answer=${a}$, status='answered', answered_at=NOW() WHERE id=${q}$",{"a":ans,"q":qid}) - return f'OK: 已回答' + await sor.sqlExe("UPDATE pipeline_agent_questions SET answer=${a}$, answer_source='main_agent', answered_by='main_agent', status='answered' WHERE id=${q}$",{"a":ans,"q":qid}) + tid = getattr(qs[0],'task_id','') or '' + if tid: + await sor.sqlExe("UPDATE pipeline_tasks SET state='submitted', claimed_by=NULL WHERE id=${t}$ AND state='waiting'",{"t":tid}) + return 'OK: 已回答' + (',任务已恢复执行' if tid else '') elif tool == 'start_agents': if not ctx['pid']: return 'FAIL: 请先切换到项目' from pipeline_service.agent_loop import role_agent_run, pm_review_run