feat(task): 添加任务修订功能和超时处理机制

添加了 `revise_task` 路由动作类型,允许用户修改、纠正或重新执行最新活动任务结果。
实现了工具失败指导原则,防止相同类别工具重复失败。
为任务规划器添加了超时处理机制,避免长时间等待。

BREAKING CHANGE: 任务路由逻辑已更新,新增 `revise_task` 动作类型。

fix(api): 修复任务详情API返回完整流程投影

修复了任务详情API端点,现在会包含过滤后的流程运行、事件和工件信息,
并确保时间戳字段正确序列化。

refactor(engine): 优化任务技能解析器摘要节点处理

改进了任务技能解析器对摘要节点的处理逻辑,对于仅依赖文本生成功能的摘要节
点不再分配具体技能,直接使用依赖项输出进行汇总。

test: 增加任务修订和超时处理测试用例

添加了测试用例验证任务修订输入记录反馈、超时回退到单模式以及
摘要节点技能解析等新功能。
This commit is contained in:
2026-05-21 16:40:44 +08:00
parent 0caca8db8a
commit a27560102b
22 changed files with 855 additions and 93 deletions

View File

@ -78,3 +78,81 @@ def test_task_delete_api_removes_backend_task(tmp_path: Path) -> None:
assert deleted.json()["task_id"] == task.task_id
assert all(item["task_id"] != task.task_id for item in listed.json())
assert missing.status_code == 404
def test_task_detail_api_includes_filtered_process_projection(tmp_path: Path) -> None:
service = AgentService(workspace=tmp_path)
loaded = service.create_loop().boot()
task = loaded.task_service.create_task( # type: ignore[union-attr]
session_id="web:detail",
description="补充赛事数据",
)
other_task = loaded.task_service.create_task( # type: ignore[union-attr]
session_id="web:detail",
description="不相关任务",
)
loaded.session_manager.append_message(
"web:detail",
role="system",
event_type="task_execution_planned",
event_payload={
"task_id": task.task_id,
"attempt_index": 2,
"plan_mode": "team",
"strategy": "parallel",
"node_ids": ["search_match_result", "search_match_stats"],
"reason": "needs separate evidence gathering",
},
context_visible=False,
)
loaded.session_manager.append_message(
"web:detail",
role="system",
event_type="task_team_run_failed",
event_payload={
"task_id": task.task_id,
"attempt_index": 2,
"plan_mode": "team",
"strategy": "parallel",
"team_success": False,
"team_run_ids": ["sub-run"],
"node_results": [
{
"node_id": "search_match_stats",
"success": False,
"output_text": "",
"run_id": "sub-run",
"finish_reason": "max_tool_iterations",
"error": "max_tool_iterations",
}
],
"error": "one or more team nodes failed",
},
context_visible=False,
)
loaded.session_manager.append_message(
"web:detail",
role="system",
event_type="task_execution_planned",
event_payload={
"task_id": other_task.task_id,
"attempt_index": 1,
"plan_mode": "single",
"strategy": None,
"node_ids": [],
},
context_visible=False,
)
app = create_app(service=service, manage_service_lifecycle=False)
with TestClient(app) as client:
response = client.get(f"/api/tasks/{task.task_id}")
assert response.status_code == 200
payload = response.json()
assert [run["run_id"] for run in payload["process_runs"]] == [
f"task:{task.task_id}:attempt:2",
"sub-run",
]
assert {event["actor_name"] for event in payload["process_events"]} == {"Task Planner", "Task Team", "search_match_stats"}
assert all(event["metadata"]["task_id"] == task.task_id for event in payload["process_events"])