vxcontrol/pentagi · warning · stateGuard

no 'created' subtasks found for task %d; all subtasks have b

Error message

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

What it means

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.

Source

Thrown at backend/pkg/tools/flow_manager.go:907

			if st.TaskID != action.TaskID {
				continue
			}
			switch st.Status {
			case database.SubtaskStatusWaiting:
				return "", stateGuard(fmt.Errorf(
					"task %d has a subtask (ID: %d, %q) waiting for user input. "+
						"Only 'created' subtasks can be patched, but you can include the waiting subtask's ID in your operations to modify or remove it. "+
						"Alternatively, answer it via %s first",
					action.TaskID, st.ID, st.Title, SubmitFlowInputToolName))
			case database.SubtaskStatusRunning:
				return "", stateGuard(fmt.Errorf(
					"task %d has a subtask (ID: %d, %q) currently running. "+
						"Call %s first, then retry",
					action.TaskID, st.ID, st.Title, StopFlowToolName))
			}
		}

		return "", stateGuard(fmt.Errorf(
			"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",
			action.TaskID, SubmitFlowInputToolName))
	}

	patch := SubtaskPatch{
		Operations: action.Operations,
		Message:    action.Message,
	}

	if err := patch.Validate(); err != nil {
		return "", fmt.Errorf("invalid subtask patch: %w", err)
	}

	if len(action.Operations) == 0 {
		return fmt.Sprintf("No operations provided — the subtask plan for task %d is unchanged.", action.TaskID), nil
	}

View on GitHub (pinned to ea665308ba)

Solutions

  1. Create a new task (with its subtask plan) via submit_flow_input instead of patching
  2. Verify the task ID is current using the flow status tool with detail='tasks' before patching
  3. If only results are needed, inspect the executed subtasks' outputs rather than patching

Example fix

// before
// patch-subtasks(task_id=42, operations=[...]) -> no 'created' subtasks
// after
// submit_flow_input(type="task", title="Re-scan 10.0.0.5", description="...", operations=[...])
Defensive patterns

Strategy: validation

Validate before calling

// before patching, confirm at least one 'created' subtask exists for the task
hasCreated := false
for _, st := range subtasks {
	if st.TaskID == taskID && st.Status == database.SubtaskStatusCreated {
		hasCreated = true
		break
	}
}
if !hasCreated {
	return fmt.Errorf("task %d has no 'created' subtasks; create a new task via submit_flow_input", taskID)
}

Try / catch

out, err := mgr.Handle(ctx, action)
if err != nil {
	if strings.Contains(err.Error(), "no 'created' subtasks found") {
		// fall back to submit_flow_input to create a new task instead of patching
	}
	return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01). Data as JSON: /api/errors/53ac4fb588e92c0c. Report an issue: GitHub.