{"record":{"id":"53ac4fb588e92c0c","repo":"vxcontrol/pentagi","slug":"no-created-subtasks-found-for-task-d-all-subta","errorCode":null,"errorMessage":"no 'created' subtasks found for task %d; all subtasks have been executed or the task has no plan yet. Use %s to create a new task instead","messagePattern":"no 'created' subtasks found for task (.+?); all subtasks have been executed or the task has no plan yet\\. Use (.+?) to create a new task instead","errorType":"validation","errorClass":"stateGuard","httpStatus":null,"severity":"warning","filePath":"backend/pkg/tools/flow_manager.go","lineNumber":907,"sourceCode":"\t\t\tif st.TaskID != action.TaskID {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tswitch st.Status {\n\t\t\tcase database.SubtaskStatusWaiting:\n\t\t\t\treturn \"\", stateGuard(fmt.Errorf(\n\t\t\t\t\t\"task %d has a subtask (ID: %d, %q) waiting for user input. \"+\n\t\t\t\t\t\t\"Only 'created' subtasks can be patched, but you can include the waiting subtask's ID in your operations to modify or remove it. \"+\n\t\t\t\t\t\t\"Alternatively, answer it via %s first\",\n\t\t\t\t\taction.TaskID, st.ID, st.Title, SubmitFlowInputToolName))\n\t\t\tcase database.SubtaskStatusRunning:\n\t\t\t\treturn \"\", stateGuard(fmt.Errorf(\n\t\t\t\t\t\"task %d has a subtask (ID: %d, %q) currently running. \"+\n\t\t\t\t\t\t\"Call %s first, then retry\",\n\t\t\t\t\taction.TaskID, st.ID, st.Title, StopFlowToolName))\n\t\t\t}\n\t\t}\n\n\t\treturn \"\", stateGuard(fmt.Errorf(\n\t\t\t\"no 'created' subtasks found for task %d; \"+\n\t\t\t\t\"all subtasks have been executed or the task has no plan yet. \"+\n\t\t\t\t\"Use %s to create a new task instead\",\n\t\t\taction.TaskID, SubmitFlowInputToolName))\n\t}\n\n\tpatch := SubtaskPatch{\n\t\tOperations: action.Operations,\n\t\tMessage:    action.Message,\n\t}\n\n\tif err := patch.Validate(); err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid subtask patch: %w\", err)\n\t}\n\n\tif len(action.Operations) == 0 {\n\t\treturn fmt.Sprintf(\"No operations provided — the subtask plan for task %d is unchanged.\", action.TaskID), nil\n\t}","sourceCodeStart":889,"sourceCodeEnd":925,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/flow_manager.go#L889-L925","documentation":"A stateGuard error raised by the patch-subtasks tool when no subtask of the target task is in the 'created' (pending) state — everything has already been executed or no plan was ever created. Since patching only applies to 'created' subtasks, the tool refuses and instructs the agent to create a new task via submit_flow_input instead. This is an expected terminal-state guard, not a system fault.","triggerScenarios":"Calling patch-subtasks with operations for a task whose planned subtasks are all completed/failed/stopped, or a task that has zero planned subtasks and none matched in the flow's subtask list.","commonSituations":"The agent attempts to revise a plan after all subtasks already ran; the task ID refers to a task whose plan was never generated or was fully consumed; the agent used a stale task ID after the flow moved on.","solutions":["Create a new task (with its subtask plan) via submit_flow_input instead of patching","Verify the task ID is current using the flow status tool with detail='tasks' before patching","If only results are needed, inspect the executed subtasks' outputs rather than patching"],"exampleFix":"// before\n// patch-subtasks(task_id=42, operations=[...]) -> no 'created' subtasks\n// after\n// submit_flow_input(type=\"task\", title=\"Re-scan 10.0.0.5\", description=\"...\", operations=[...])","handlingStrategy":"validation","validationCode":"// before patching, confirm at least one 'created' subtask exists for the task\nhasCreated := false\nfor _, st := range subtasks {\n\tif st.TaskID == taskID && st.Status == database.SubtaskStatusCreated {\n\t\thasCreated = true\n\t\tbreak\n\t}\n}\nif !hasCreated {\n\treturn fmt.Errorf(\"task %d has no 'created' subtasks; create a new task via submit_flow_input\", taskID)\n}","typeGuard":null,"tryCatchPattern":"out, err := mgr.Handle(ctx, action)\nif err != nil {\n\tif strings.Contains(err.Error(), \"no 'created' subtasks found\") {\n\t\t// fall back to submit_flow_input to create a new task instead of patching\n\t}\n\treturn err\n}","preventionTips":["Fetch current flow status (detail='tasks') to confirm the task still has pending subtasks before patching","Use fresh task IDs; stale IDs from earlier in the flow often point to exhausted plans","If the plan is done, create a new task rather than patching","Handle the fallback path in agent prompts: patch only while subtasks are pending"],"tags":["flow-manager","state-guard","agent-tools","subtask-status"],"backgroundTag":"no-created-subtasks","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}