fix: cockpit v1 answer_question 回答后恢复任务 waiting→submitted(清 claimed_by)

This commit is contained in:
ymq 2026-08-15 00:11:48 +08:00
parent 5e84ddbb07
commit f519f48dd5

View File

@ -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