Tencent/WeKnora · error
invalid totalThoughts: must be >= 1
Error message
invalid totalThoughts: must be >= 1
What it means
SequentialThinkingTool.validate returns this error when TotalThoughts is less than 1. The protocol requires the model to declare how many thinking steps are planned, and at least one step must exist. Validate runs inside Execute, so the call fails before the thought is processed.
Source
Thrown at internal/agent/tools/sequentialthinking.go:255
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
- Set TotalThoughts to an integer >= 1 reflecting the planned number of thinking steps.
- Validate or default TotalThoughts (e.g. to 1) before invoking Execute.
- If the plan length is unknown, have the model revise and estimate a step count.
Example fix
// before
in := SequentialThinkingInput{Thought: "step text", ThoughtNumber: 1, TotalThoughts: 0}
// after
in := SequentialThinkingInput{Thought: "step text", ThoughtNumber: 1, TotalThoughts: 3} Defensive patterns
Strategy: validation
Validate before calling
if input.TotalThoughts < 1 {
return errors.New("totalThoughts must be >= 1")
} Type guard
func validTotalThoughts(in SequentialThinkingInput) bool { return in.TotalThoughts >= 1 } Try / catch
if err := tool.Execute(ctx, input); err != nil && strings.Contains(err.Error(), "invalid totalThoughts") {
input.TotalThoughts = input.ThoughtNumber // assume current step is last, then retry
} Prevention
- Always declare a planned step count >= 1 in sequential-thinking calls
- Guard against len()-derived zero counts before assigning TotalThoughts
- Mark totalThoughts required in the tool schema so providers must supply it
When it happens
Trigger: Calling Execute with SequentialThinkingInput.TotalThoughts == 0 or negative — usually a zero-valued field because totalThoughts was omitted from the tool-call JSON or never set by the caller.
Common situations: Model omits totalThoughts in its tool arguments; caller constructs the input without the planned step count; code that computes TotalThoughts from an empty slice (len 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
- invalid thought: must be a non-empty string
- invalid thoughtNumber: must be >= 1
- missing query
- invite code has expired
- join request not found
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/9c72e8c624d2ed94.
Report an issue: GitHub.