{"record":{"id":"a013465a7cc5b3a2","repo":"Tencent/WeKnora","slug":"invalid-thoughtnumber-must-be-1","errorCode":null,"errorMessage":"invalid thoughtNumber: must be >= 1","messagePattern":"invalid thoughtNumber: must be >= 1","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/sequentialthinking.go","lineNumber":250,"sourceCode":"\t}\n\n\treturn &types.ToolResult{\n\t\tSuccess: true,\n\t\tOutput:  outputMsg,\n\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":232,"sourceCodeEnd":260,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/sequentialthinking.go#L232-L260","documentation":"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.","triggerScenarios":"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.","commonSituations":"Model omits the thoughtNumber key; caller builds the input struct with only Thought set; off-by-one code that starts counting steps at 0.","solutions":["Set ThoughtNumber to a value >= 1 matching the current step index.","Validate/normalize the input (e.g. default ThoughtNumber to 1) before calling Execute.","Ensure the model's JSON includes an integer thoughtNumber >= 1."],"exampleFix":"// before\nin := SequentialThinkingInput{Thought: \"step text\", ThoughtNumber: 0, TotalThoughts: 3}\n// after\nin := SequentialThinkingInput{Thought: \"step text\", ThoughtNumber: 1, TotalThoughts: 3}","handlingStrategy":"validation","validationCode":"if input.ThoughtNumber < 1 {\n    return errors.New(\"thoughtNumber must be >= 1\")\n}","typeGuard":"func validThoughtNumber(in SequentialThinkingInput) bool { return in.ThoughtNumber >= 1 }","tryCatchPattern":"if err := tool.Execute(ctx, input); err != nil && strings.Contains(err.Error(), \"invalid thoughtNumber\") {\n    input.ThoughtNumber = 1 // or correct and retry once\n}","preventionTips":["Number thinking steps starting from 1, not 0","Default thoughtNumber to 1 when omitted by the model","Declare thoughtNumber as a required integer >= 1 in the tool schema"],"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"}