Tencent/WeKnora · error

invalid thoughtNumber: must be >= 1

Error message

invalid thoughtNumber: must be >= 1

What it means

SequentialThinkingTool.validate returns this error when ThoughtNumber is less than 1. Thought numbering is 1-based, so 0 or negative values indicate malformed progress tracking. Execute invokes validate before processing, so the call is rejected outright.

Source

Thrown at internal/agent/tools/sequentialthinking.go:250

	}

	return &types.ToolResult{
		Success: true,
		Output:  outputMsg,
		Data:    responseData,
	}, nil
}

// validate validates the input thought data
func (t *SequentialThinkingTool) validate(data SequentialThinkingInput) error {
	// Validate thought (required)
	if data.Thought == "" {
		return fmt.Errorf("invalid thought: must be a non-empty string")
	}

	// Validate thoughtNumber (required)
	if data.ThoughtNumber < 1 {
		return fmt.Errorf("invalid thoughtNumber: must be >= 1")
	}

	// Validate totalThoughts (required)
	if data.TotalThoughts < 1 {
		return fmt.Errorf("invalid totalThoughts: must be >= 1")
	}

	return nil
}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Set ThoughtNumber to a value >= 1 matching the current step index.
  2. Validate/normalize the input (e.g. default ThoughtNumber to 1) before calling Execute.
  3. Ensure the model's JSON includes an integer thoughtNumber >= 1.

Example fix

// before
in := SequentialThinkingInput{Thought: "step text", ThoughtNumber: 0, TotalThoughts: 3}
// after
in := SequentialThinkingInput{Thought: "step text", ThoughtNumber: 1, TotalThoughts: 3}
Defensive patterns

Strategy: validation

Validate before calling

if input.ThoughtNumber < 1 {
    return errors.New("thoughtNumber must be >= 1")
}

Type guard

func validThoughtNumber(in SequentialThinkingInput) bool { return in.ThoughtNumber >= 1 }

Try / catch

if err := tool.Execute(ctx, input); err != nil && strings.Contains(err.Error(), "invalid thoughtNumber") {
    input.ThoughtNumber = 1 // or correct and retry once
}

Prevention

When it happens

Trigger: Calling Execute with SequentialThinkingInput.ThoughtNumber == 0 or negative — typically a zero-valued struct field because the JSON argument omitted thoughtNumber or the caller never set it.

Common situations: Model omits the thoughtNumber key; caller builds the input struct with only Thought set; off-by-one code that starts counting steps at 0.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/a013465a7cc5b3a2. Report an issue: GitHub.