{"record":{"id":"9c72e8c624d2ed94","repo":"Tencent/WeKnora","slug":"invalid-totalthoughts-must-be-1","errorCode":null,"errorMessage":"invalid totalThoughts: must be >= 1","messagePattern":"invalid totalThoughts: must be >= 1","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/sequentialthinking.go","lineNumber":255,"sourceCode":"\t\tData:    responseData,\n\t}, nil\n}\n\n// validate validates the input thought data\nfunc (t *SequentialThinkingTool) validate(data SequentialThinkingInput) error {\n\t// Validate thought (required)\n\tif data.Thought == \"\" {\n\t\treturn fmt.Errorf(\"invalid thought: must be a non-empty string\")\n\t}\n\n\t// Validate thoughtNumber (required)\n\tif data.ThoughtNumber < 1 {\n\t\treturn fmt.Errorf(\"invalid thoughtNumber: must be >= 1\")\n\t}\n\n\t// Validate totalThoughts (required)\n\tif data.TotalThoughts < 1 {\n\t\treturn fmt.Errorf(\"invalid totalThoughts: must be >= 1\")\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":237,"sourceCodeEnd":260,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/sequentialthinking.go#L237-L260","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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."],"exampleFix":"// before\nin := SequentialThinkingInput{Thought: \"step text\", ThoughtNumber: 1, TotalThoughts: 0}\n// after\nin := SequentialThinkingInput{Thought: \"step text\", ThoughtNumber: 1, TotalThoughts: 3}","handlingStrategy":"validation","validationCode":"if input.TotalThoughts < 1 {\n    return errors.New(\"totalThoughts must be >= 1\")\n}","typeGuard":"func validTotalThoughts(in SequentialThinkingInput) bool { return in.TotalThoughts >= 1 }","tryCatchPattern":"if err := tool.Execute(ctx, input); err != nil && strings.Contains(err.Error(), \"invalid totalThoughts\") {\n    input.TotalThoughts = input.ThoughtNumber // assume current step is last, then retry\n}","preventionTips":["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"],"tags":["validation","sequential-thinking","tool-input"],"backgroundTag":"schema-validation-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}