fix: per conversation sub agent limit and todo hints
This commit is contained in:
parent
1c4a7ba003
commit
3eec18b8a9
@ -1976,10 +1976,18 @@ class MainTerminal:
|
||||
)
|
||||
|
||||
elif tool_name == "wait_sub_agent":
|
||||
wait_timeout = arguments.get("timeout_seconds")
|
||||
if not wait_timeout:
|
||||
task_ref = self.sub_agent_manager.lookup_task(
|
||||
task_id=arguments.get("task_id"),
|
||||
agent_id=arguments.get("agent_id")
|
||||
)
|
||||
if task_ref:
|
||||
wait_timeout = task_ref.get("timeout_seconds")
|
||||
result = self.sub_agent_manager.wait_for_completion(
|
||||
task_id=arguments.get("task_id"),
|
||||
agent_id=arguments.get("agent_id"),
|
||||
timeout_seconds=arguments.get("timeout_seconds")
|
||||
timeout_seconds=wait_timeout
|
||||
)
|
||||
self._record_sub_agent_message(result.get("system_message"), result.get("task_id"), inline=False)
|
||||
|
||||
|
||||
@ -317,6 +317,19 @@ class SubAgentManager:
|
||||
return candidates[0]
|
||||
return None
|
||||
|
||||
def lookup_task(self, *, task_id: Optional[str] = None, agent_id: Optional[int] = None) -> Optional[Dict]:
|
||||
"""只读查询任务信息,供 wait_sub_agent 自动调整超时时间。"""
|
||||
task = self._select_task(task_id, agent_id)
|
||||
if not task:
|
||||
return None
|
||||
return {
|
||||
"task_id": task.get("task_id"),
|
||||
"agent_id": task.get("agent_id"),
|
||||
"status": task.get("status"),
|
||||
"timeout_seconds": task.get("timeout_seconds"),
|
||||
"conversation_id": task.get("conversation_id"),
|
||||
}
|
||||
|
||||
def poll_updates(self) -> List[Dict]:
|
||||
"""检查运行中的子智能体任务,返回新完成的结果。"""
|
||||
updates: List[Dict] = []
|
||||
|
||||
@ -68,7 +68,10 @@ class TodoManager:
|
||||
|
||||
overview = (overview or "").strip()
|
||||
if not overview:
|
||||
return {"success": False, "error": "任务概述不能为空。"}
|
||||
return {
|
||||
"success": False,
|
||||
"error": "任务概述不能为空。请用一句话概括清单目标,例如“整理比亚迪新能源销量数据”。"
|
||||
}
|
||||
if len(overview) > self.MAX_OVERVIEW_LENGTH:
|
||||
return {
|
||||
"success": False,
|
||||
@ -77,7 +80,10 @@ class TodoManager:
|
||||
|
||||
normalized_tasks = self._normalize_tasks(tasks or [])
|
||||
if not normalized_tasks:
|
||||
return {"success": False, "error": "需要至少提供一个任务。"}
|
||||
return {
|
||||
"success": False,
|
||||
"error": "需要至少提供一个任务。每个任务应是可执行的步骤,如“收集车型销量数据”而不是“处理”这类模糊词。"
|
||||
}
|
||||
if len(tasks or []) > self.MAX_TASKS:
|
||||
return {
|
||||
"success": False,
|
||||
|
||||
@ -68,7 +68,10 @@ class TodoManager:
|
||||
|
||||
overview = (overview or "").strip()
|
||||
if not overview:
|
||||
return {"success": False, "error": "任务概述不能为空。"}
|
||||
return {
|
||||
"success": False,
|
||||
"error": "任务概述不能为空。请用一句话概括清单目标,例如“整理车型销量”或“编写 result.md”。"
|
||||
}
|
||||
if len(overview) > self.MAX_OVERVIEW_LENGTH:
|
||||
return {
|
||||
"success": False,
|
||||
@ -77,7 +80,10 @@ class TodoManager:
|
||||
|
||||
normalized_tasks = self._normalize_tasks(tasks or [])
|
||||
if not normalized_tasks:
|
||||
return {"success": False, "error": "需要至少提供一个任务。"}
|
||||
return {
|
||||
"success": False,
|
||||
"error": "需要至少提供一个任务。请把计划分成可执行的小步骤,例如“读取文件”“整理总结”等。"
|
||||
}
|
||||
if len(tasks or []) > self.MAX_TASKS:
|
||||
return {
|
||||
"success": False,
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
## 使用流程
|
||||
1. **先规划**:在创建清单前,用自然语言写下你准备执行的流程,让自己确认无遗漏。
|
||||
2. **todo_create**:把概述与任务数组一次性写对,创建后尽量不要反复删除重建。
|
||||
2. **todo_create**:把概述与任务数组一次性写对,创建后尽量不要反复删除重建。概述 ≤ 50 字,直接写清“我要做什么”;任务数组列出 2~4 条动词+对象的步骤,例如“读取 physics_problems.txt”“整理 result.md 结论”。
|
||||
3. **todo_update_task**:每完成一项立刻勾选;若步骤发生变化,先写明原因再修改对应任务。
|
||||
4. **todo_finish**:所有任务完成后调用。若仍有未完项但必须停止,先调用 `todo_finish`,再用 `todo_finish_confirm` 说明原因与后续建议。
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user