mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-12-01 16:33:27 +01:00
Merge pull request #429 from Sycun/fix/pi-unfinished-plan-prompt
fix(pi): warn plan_execute that unfinished todos block the run
This commit is contained in:
5 files changed
+12
-4
No files matched your search
@@ -8,7 +8,7 @@ description: plan_execute 模式下的规划/重规划侧主代理:拆解目
|
||||
|
||||
## Pi 执行协议
|
||||
|
||||
使用可用的 write_todos 或 TaskCreate/TaskUpdate 维护计划。每一步通过 task 调用 `subagent_type=executor`,在 description 中写清目标、范围、动作和成功标准。根据执行器返回的真实证据再决定继续、调整或结束。不要只输出计划 JSON 就把任务标为完成;最终交付通过 exit 提交,仍需经过宿主验收。
|
||||
使用可用的 write_todos 或 TaskCreate/TaskUpdate 维护计划。每一步通过 task 调用 `subagent_type=executor`,在 description 中写清目标、范围、动作和成功标准。根据执行器返回的真实证据再决定继续、调整或结束。不要只输出计划 JSON 就把任务标为完成;本轮计划中仍为 pending/in_progress 的步骤会使本轮被判为未完成(unfinished_plan)且不会自动续跑,调用 exit 前须把每一步更新为 completed(不再执行的步骤从计划中移除);最终交付通过 exit 提交,仍需经过宿主验收。
|
||||
|
||||
## 计划与执行器上下文(强制)
|
||||
|
||||
|
||||
@@ -44,6 +44,14 @@ func TestShouldAutoContinueAfterFinalization(t *testing.T) {
|
||||
if shouldAutoContinueAfterFinalization(awaitingHITL, 0) {
|
||||
t.Fatal("awaiting HITL should not auto-continue without approval")
|
||||
}
|
||||
|
||||
unfinishedPlan := agentfinalizer.Decision{
|
||||
Status: agentfinalizer.StatusBlocked,
|
||||
CompletionReason: multiagent.ReasonUnfinishedPlan,
|
||||
}
|
||||
if shouldAutoContinueAfterFinalization(unfinishedPlan, 0) {
|
||||
t.Fatal("an unfinished plan should not auto-continue")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRequestRequiresExecutionEvidenceUsesExplicitPolicyOnly(t *testing.T) {
|
||||
|
||||
@@ -168,7 +168,7 @@ func finalizationBlockedMessage(d agentfinalizer.Decision) string {
|
||||
case agentfinalizer.ReasonPendingToolsCancelled:
|
||||
notice = "收尾时取消了仍在运行的工具,任务未完成。"
|
||||
case multiagent.ReasonUnfinishedPlan:
|
||||
notice = "本轮执行计划仍有未完成的步骤。"
|
||||
notice = "本轮计划仍有标记为「待执行」或「进行中」的步骤,最终回复暂未交付。请核对计划中的步骤状态。"
|
||||
case multiagent.ReasonModelOutputTruncated:
|
||||
notice = "模型输出达到长度上限,本轮回复未完成。"
|
||||
default:
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
func DefaultPlanExecuteOrchestratorInstruction() string {
|
||||
return `你是 CyberStrikeAI 的 Pi 计划执行协调者。
|
||||
将用户目标、已知范围、约束和验收要求整理为少量可执行步骤。使用可用的任务板工具记录进度,通过 task 委派 executor 执行具体步骤,并根据真实工具结果更新后续计划。
|
||||
将用户目标、已知范围、约束和验收要求整理为少量可执行步骤。使用可用的任务板工具记录进度,通过 task 委派 executor 执行具体步骤,并根据真实工具结果更新后续计划。本轮结束时仍为 pending/in_progress 的步骤会使本轮被判为未完成(unfinished_plan)且不会自动续跑;调用 exit 前须把每一步更新为 completed,不再执行的步骤从计划中移除。
|
||||
每次委派说明目标、已知证据、允许的操作与期望输出。不要把计划、尝试和已完成的工作混为一谈;记录执行 ID、未解决的问题和覆盖缺口。
|
||||
优先使用已注册的工具和匹配的技能。工具失败时区分参数、网络、服务与权限原因;遵守预算和人工决定。已有证据可复用,避免重复有副作用的操作。
|
||||
需要用户作出关键取舍或补充无法可靠推断的信息时,说明已完成的工作、阻碍及具体选项。最终只交付已验证的结果;任务未完成时明确说明剩余工作。`
|
||||
|
||||
@@ -129,7 +129,7 @@ func runPiMulti(ctx context.Context, cfg *config.Config, ma *config.MultiAgentCo
|
||||
str := map[string]any{"type": "string"}
|
||||
main.extraTools = []agentruntime.Tool{
|
||||
{Name: "task", Description: "Delegate a concrete task to a named specialist and return its evidence-backed result", Parameters: piToolSchema(map[string]any{"subagent_type": str, "description": str}, "subagent_type", "description")},
|
||||
{Name: "write_todos", Description: "Record/update the execution plan", Parameters: piToolSchema(map[string]any{"todos": map[string]any{"type": "array", "items": map[string]any{"type": "object", "properties": map[string]any{"content": str, "status": map[string]any{"type": "string", "enum": []string{"pending", "in_progress", "completed"}}}, "required": []string{"content", "status"}}}}, "todos")},
|
||||
{Name: "write_todos", Description: "Record/update the execution plan (replaces the whole list). Items left pending or in_progress when you finish keep the run from completing; mark each item completed once done and drop items you abandon.", Parameters: piToolSchema(map[string]any{"todos": map[string]any{"type": "array", "items": map[string]any{"type": "object", "properties": map[string]any{"content": str, "status": map[string]any{"type": "string", "enum": []string{"pending", "in_progress", "completed"}}}, "required": []string{"content", "status"}}}}, "todos")},
|
||||
}
|
||||
var idsMu sync.Mutex
|
||||
var childIDs []string
|
||||
|
||||
Reference in new issue
Block a user