{"record":{"id":"11d5c941c4ee86df","repo":"vxcontrol/pentagi","slug":"unknown-tool-s-11d5c9","errorCode":null,"errorMessage":"unknown tool: %s","messagePattern":"unknown tool: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/search.go","lineNumber":384,"sourceCode":"\t\t\t}\n\t\t\t_, _ = s.vslp.PutLog(\n\t\t\t\tctx,\n\t\t\t\tagentCtx.ParentAgentType,\n\t\t\t\tagentCtx.CurrentAgentType,\n\t\t\t\tfiltersData,\n\t\t\t\taction.Question,\n\t\t\t\tdatabase.VecstoreActionTypeStore,\n\t\t\t\taction.Answer,\n\t\t\t\ts.taskID,\n\t\t\t\ts.subtaskID,\n\t\t\t)\n\t\t}\n\n\t\treturn \"answer for question stored successfully\", nil\n\n\tdefault:\n\t\tlogger.Error(\"unknown tool\")\n\t\treturn \"\", fmt.Errorf(\"unknown tool: %s\", name)\n\t}\n}\n\nfunc (s *search) IsAvailable() bool {\n\treturn s.store != nil\n}\n","sourceCodeStart":366,"sourceCodeEnd":391,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/search.go#L366-L391","documentation":"The search tool's Handle dispatches on the tool `name` (action name). If the agent requests an action not among the implemented switch cases (e.g. `question`/`store_answer`), the default branch returns `unknown tool: <name>`. It signals a mismatch between the tool-calling schema advertised to the LLM and the dispatcher's implemented cases.","triggerScenarios":"An LLM emits a tool call whose name does not match any case handled by search.Handle — e.g. the model hallucinates an action name, or a prompt/schema declares an action that the switch does not implement.","commonSituations":"Prompt edits adding a new action type without updating the switch; LLM hallucinating action names under a weak model; copy/paste of tool schemas from another tool collection; provider tool-call name truncation or case mismatch.","solutions":["Log the exact `name` value in the error and compare against the switch cases in search.go; add a case for the missing action if it should be supported.","Tighten the tool schema/prompt so only implemented action names are advertised to the model.","If the name is a hallucination, retry the request with a stronger model or add explicit few-shot examples of valid action names.","Normalize the incoming name (trim/case-fold) before dispatch if providers vary formatting."],"exampleFix":"// before\ndefault:\n    return \"\", fmt.Errorf(\"unknown tool: %s\", name)\n// after\ndefault:\n    return \"\", fmt.Errorf(\"unknown tool: %q; valid actions: %v\", name, []string{\"question\", \"store_answer\"})","handlingStrategy":"validation","validationCode":"var validActions = map[string]bool{\"question\": true, \"store_answer\": true}\nif !validActions[name] {\n    return \"\", fmt.Errorf(\"unknown tool: %s\", name)\n}","typeGuard":null,"tryCatchPattern":"result, err := searchTool.Handle(ctx, req)\nif err != nil {\n    var uerr *UnknownToolError\n    if errors.As(err, &uerr) {\n        // re-prompt the LLM with the list of valid actions\n    }\n    return err\n}","preventionTips":["Keep the advertised tool schema and the switch cases in sync — generate one from the other","Add a table-driven test iterating every advertised action name through Handle","Include the valid action list in the error message for faster diagnosis","Normalize (trim, lowercase) the incoming name before dispatch"],"tags":["tool-dispatch","llm","go"],"backgroundTag":"unknown-tool-name","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}