vxcontrol/pentagi · error

operation %d: reorder requires id

Error message

operation %d: reorder requires id

What it means

SubtaskPatch.Validate requires a non-nil ID for SubtaskOpReorder; this error fires when a reorder operation omits the ID of the subtask to move. Without it the position change cannot be attributed to a subtask.

Source

Thrown at backend/pkg/tools/args.go:341

				return fmt.Errorf("operation %d: add requires title", i)
			}
			if op.Description == "" {
				return fmt.Errorf("operation %d: add requires description", i)
			}
		case SubtaskOpRemove:
			if op.ID == nil {
				return fmt.Errorf("operation %d: remove requires id", i)
			}
		case SubtaskOpModify:
			if op.ID == nil {
				return fmt.Errorf("operation %d: modify requires id", i)
			}
			if op.Title == "" && op.Description == "" {
				return fmt.Errorf("operation %d: modify requires at least title or description", i)
			}
		case SubtaskOpReorder:
			if op.ID == nil {
				return fmt.Errorf("operation %d: reorder requires id", i)
			}
		default:
			return fmt.Errorf("operation %d: unknown operation type %q", i, op.Op)
		}
	}
	return nil
}

type Bool bool

func (b *Bool) UnmarshalJSON(data []byte) error {
	sdata := strings.Trim(strings.ToLower(string(data)), "' \"\n\r\t")
	switch sdata {
	case "true":
		*b = true
	case "false":
		*b = false
	default:

View on GitHub (pinned to ea665308ba)

Solutions

  1. Resolve each subtask ID via get_flow_status detail=subtasks and set it on each reorder op.
  2. Pre-validate ops and skip/fix reorder entries with nil ID.
  3. Update tool schema descriptions/prompt to stress the required id for reorder.

Example fix

// before
ops := []SubtaskOperation{{Op: SubtaskOpReorder, Position: int64Ptr(1)}}
// after
ops := []SubtaskOperation{{Op: SubtaskOpReorder, ID: int64Ptr(12), Position: int64Ptr(1)}}
Defensive patterns

Strategy: type-guard

Validate before calling

for i, op := range ops {
    if op.Op == "reorder" && op.ID == nil {
        return fmt.Errorf("op %d: reorder needs id", i)
    }
}

Type guard

func reorderableOp(op SubtaskOperation) bool {
    return op.Op == SubtaskOpReorder && op.ID != nil
}

Try / catch

if err := patch.Validate(); err != nil {
    if strings.Contains(err.Error(), "reorder requires id") {
        // fetch plan, resolve IDs, rebuild reorder ops with explicit IDs
    }
}

Prevention

When it happens

Trigger: Patch operation {"op":"reorder"} without "id" (position fields only), submitted through patch_flow_subtasks or SubtaskPatch.Validate.

Common situations: LLM tries to reorder 'the second subtask' by index without resolving its ID; batch reorder scripts that emit only positions.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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