{"record":{"id":"2829f05d3964f919","repo":"Tencent/WeKnora","slug":"invalid-thought-must-be-a-non-empty-string","errorCode":null,"errorMessage":"invalid thought: must be a non-empty string","messagePattern":"invalid thought: must be a non-empty string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/sequentialthinking.go","lineNumber":245,"sourceCode":"\t)\n\n\toutputMsg := \"Thought process recorded\"\n\tif incomplete {\n\t\toutputMsg = \"Thought process recorded - unfinished steps remain, continue exploring and calling tools\"\n\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":227,"sourceCodeEnd":260,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/sequentialthinking.go#L227-L260","documentation":"SequentialThinkingTool.validate rejects input whose Thought field is the empty string, since every reasoning step must carry actual thought text. Execute calls validate first, so this error aborts the tool call before any state is recorded. It enforces the required-argument contract of the sequential-thinking protocol.","triggerScenarios":"Calling Execute with SequentialThinkingInput where Thought == \"\", e.g. the model supplied only thoughtNumber/totalThoughts or the JSON argument omitted the thought field entirely.","commonSituations":"Model emits an empty thought argument; prompt scaffolding leaves the thought blank; JSON unmarshalling into the input struct drops a missing/empty \"thought\" key.","solutions":["Provide a non-empty Thought string in the tool input.","Validate that the thought argument is present and non-blank before calling Execute.","If the model produced an empty thought, re-issue the request with clearer instructions."],"exampleFix":"// before\nin := SequentialThinkingInput{Thought: \"\", ThoughtNumber: 1, TotalThoughts: 3}\n// after\nin := SequentialThinkingInput{Thought: \"Analyze the request structure\", ThoughtNumber: 1, TotalThoughts: 3}","handlingStrategy":"validation","validationCode":"if input.Thought == \"\" {\n    return errors.New(\"sequential thinking input requires a non-empty thought\")\n}","typeGuard":"func validThought(in SequentialThinkingInput) bool { return in.Thought != \"\" }","tryCatchPattern":"if err := tool.Execute(ctx, input); err != nil && strings.Contains(err.Error(), \"invalid thought\") {\n    // re-request the thought from the model or drop the step\n}","preventionTips":["Enforce required fields in the tool-call JSON schema","Validate tool inputs at the boundary before dispatching to Execute","Reject empty model arguments with a re-prompt loop"],"tags":["validation","sequential-thinking","tool-input"],"backgroundTag":"missing-required-argument","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}