{"record":{"id":"d60e363c9c4f047a","repo":"Tencent/WeKnora","slug":"tool-not-found-s","errorCode":null,"errorMessage":"tool not found: %s","messagePattern":"tool not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/registry.go","lineNumber":69,"sourceCode":"\n// RegisterTool adds a tool to the registry.\n// If a tool with the same name is already registered, the existing one is kept\n// (first-wins) to prevent tool execution hijacking via name collision (GHSA-67q9-58vj-32qx).\nfunc (r *ToolRegistry) RegisterTool(tool types.Tool) {\n\tname := tool.Name()\n\tif _, exists := r.tools[name]; exists {\n\t\tlogger.Warnf(context.Background(),\n\t\t\t\"[ToolRegistry] Duplicate tool registration rejected: %s (first-wins policy)\", name)\n\t\treturn\n\t}\n\tr.tools[name] = tool\n}\n\n// GetTool retrieves a tool by name\nfunc (r *ToolRegistry) GetTool(name string) (types.Tool, error) {\n\ttool, exists := r.tools[name]\n\tif !exists {\n\t\treturn nil, fmt.Errorf(\"tool not found: %s\", name)\n\t}\n\treturn tool, nil\n}\n\n// ListTools returns all registered tool names sorted alphabetically.\n// Sorting keeps the order stable across calls — Go map iteration is\n// intentionally randomized.\nfunc (r *ToolRegistry) ListTools() []string {\n\tnames := make([]string, 0, len(r.tools))\n\tfor name := range r.tools {\n\t\tnames = append(names, name)\n\t}\n\tsort.Strings(names)\n\treturn names\n}\n\n// GetFunctionDefinitions returns function definitions for all registered tools.\n// The slice is sorted by tool name so the serialized payload sent to the LLM","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/registry.go#L51-L87","documentation":"Registry lookup miss: GetTool was asked for a name that was never registered (or lost to the first-wins duplicate policy), so there is no tool implementation to dispatch to; callers ExecuteTool/MCP handlers receive this as a dispatch failure.","triggerScenarios":"Thrown at internal/agent/tools/registry.go:69 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the tool name spelling against registered tool names","Register the expected tool before dispatch","Check whether a duplicate registration was rejected by the first-wins policy"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}