feat: 清理 control_node + 引入 task 一等公民
- control_node 标注 DEPRECATED:保留目录壳子供未来远程探针节点复用,删除调用路径与相关测试
- 新增 task 表:极简元数据持久化 regulatory_node 完成的短任务(出报告/写文件/查询整理)
- regulatory_node 自标注:MessageResponse 扩展 task_action/title/summary,_run 末尾非阻塞落库
- query_task_list 改查 task 表,符合用户对"任务列表"的直觉,与 workflow 体系解耦
- 新增 /api/v1/task/list|/{id} 只读 API(task 由 regulatory 内部触发,不开放对外创建)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
"name": "tavily_search",
|
||||
"file": "tavily_search.py",
|
||||
"is_system": false,
|
||||
"action_scope": ["control_node", "consciousness_node", "regulatory_node"],
|
||||
"action_scope": ["consciousness_node", "regulatory_node"],
|
||||
"config_args": {
|
||||
"api_key": "",
|
||||
"max_results": "5",
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
"""query_task_list:列出当前用户的所有工作流任务。
|
||||
"""query_task_list:列出当前用户的短任务记录。
|
||||
|
||||
regulatory_node 用以回答"我有哪些任务/正在跑什么"。返回精简后的任务列表,
|
||||
不包含 graph state、context 等大字段。
|
||||
regulatory_node 用以回答"我之前那份报告呢""昨天那个查询结果是什么"。
|
||||
返回 task 表中的精简元数据列表(不含工作流的 graph state、context 等)。
|
||||
|
||||
注:此处的 "task" 是 regulatory_node 完成的轻量短任务(出报告/写文件/查询整理等),
|
||||
与 workflow(多步骤复杂任务)是两套独立体系。如需查工作流进度,使用 query_workflow_status。
|
||||
"""
|
||||
|
||||
from typing import Any, Dict, List, Optional
|
||||
@@ -14,41 +17,40 @@ async def query_task_list(
|
||||
status_filter: Optional[str] = None,
|
||||
limit: int = 20,
|
||||
) -> Dict[str, Any]:
|
||||
"""列出当前用户的工作流任务。
|
||||
"""列出当前用户的短任务记录,按时间倒序。
|
||||
|
||||
Args:
|
||||
user_id: 用户 ID(通常由调用方从对话上下文中带入)
|
||||
status_filter: 可选,按状态过滤(pending/running/completed/failed)
|
||||
status_filter: 可选,按状态过滤(running/completed/failed)
|
||||
limit: 最多返回条数,默认 20
|
||||
|
||||
Returns:
|
||||
{
|
||||
"user_id": str,
|
||||
"tasks": [
|
||||
{"trace_id": ..., "title": ..., "status": ..., "command": ..., "created_at": ...}
|
||||
{"task_id": ..., "title": ..., "status": ...,
|
||||
"result_summary": ..., "created_at": ...}
|
||||
],
|
||||
"total": int
|
||||
}
|
||||
"""
|
||||
pg = ray_actor_hook("postgres_database").postgres_database
|
||||
workflows = await pg.list_workflows.remote(user_id) or []
|
||||
rows: List[Dict[str, Any]] = await pg.list_tasks_by_user.remote(
|
||||
user_id=user_id,
|
||||
status=status_filter,
|
||||
limit=limit,
|
||||
) or []
|
||||
|
||||
tasks: List[Dict[str, Any]] = []
|
||||
for wf in workflows:
|
||||
status = getattr(wf, "status", None)
|
||||
if status_filter and status != status_filter:
|
||||
continue
|
||||
tasks.append(
|
||||
{
|
||||
"trace_id": getattr(wf, "trace_id", None),
|
||||
"title": getattr(wf, "title", None),
|
||||
"status": status,
|
||||
"command": getattr(wf, "command", None),
|
||||
"created_at": str(getattr(wf, "created_at", "")),
|
||||
}
|
||||
)
|
||||
if len(tasks) >= limit:
|
||||
break
|
||||
tasks = [
|
||||
{
|
||||
"task_id": r.get("task_id"),
|
||||
"title": r.get("title"),
|
||||
"status": r.get("status"),
|
||||
"result_summary": r.get("result_summary"),
|
||||
"created_at": r.get("created_at"),
|
||||
}
|
||||
for r in rows
|
||||
]
|
||||
|
||||
return {
|
||||
"user_id": user_id,
|
||||
|
||||
Reference in New Issue
Block a user