{"record":{"id":"cde65c6584659afb","repo":"vxcontrol/pentagi","slug":"unknown-tool-s-cde65c","errorCode":null,"errorMessage":"unknown tool: %s","messagePattern":"unknown tool: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/memory.go","lineNumber":243,"sourceCode":"\t\t\tqueriesText := strings.Join(action.Questions, \"\\n--------------------------------\\n\")\n\t\t\t_, _ = m.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\tqueriesText,\n\t\t\t\tdatabase.VecstoreActionTypeRetrieve,\n\t\t\t\tbuffer.String(),\n\t\t\t\taction.TaskID.PtrInt64(),\n\t\t\t\taction.SubtaskID.PtrInt64(),\n\t\t\t)\n\t\t}\n\n\t\treturn buffer.String(), nil\n\n\tdefault:\n\t\tlogger.Error(\"unknown tool\")\n\t\treturn \"\", fmt.Errorf(\"unknown tool: %s\", name)\n\t}\n}\n\nfunc (m *memory) IsAvailable() bool {\n\treturn m.store != nil\n}\n\nfunc getGlobalFilters(filters map[string]any) (bool, map[string]any) {\n\tglobalFilters := maps.Clone(filters)\n\tdelete(globalFilters, \"task_id\")\n\tdelete(globalFilters, \"subtask_id\")\n\treturn len(globalFilters) != len(filters), globalFilters\n}\n","sourceCodeStart":225,"sourceCodeEnd":257,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/memory.go#L225-L257","documentation":"The memory tool dispatcher received a tool `name` that is not one of the tool names handled by its `switch` (e.g. not `SearchInMemoryToolName` or the other memory tool names). The library returns a generic 'unknown tool' error so callers know the name is not registered on this tool implementation.","triggerScenarios":"Calling `memory.Handle(ctx, name, args)` with a name string that doesn't match any `case` in the switch — typically a typo, wrong casing, or passing a tool name belonging to another tool implementation (e.g. `search_answer`).","commonSituations":"Agent framework routes tool calls by model-emitted name and the model hallucinated a tool name; tool registry wiring registered the memory tool under a different constant; refactoring renamed a tool constant but old prompts/caches still use the previous name.","solutions":["Log the received `name` and compare it against the exported `*ToolName` constants in the package.","Ensure only the intended tool definitions are advertised to the LLM so it cannot select unregistered names.","Verify the dispatcher routes each tool name to the correct implementation (memory vs search tool).","Check for casing/renaming drift between the model's tool list and the switch cases."],"exampleFix":"// before\nout, err := mem.Handle(ctx, \"search_in_memory \", args) // trailing space/casing mismatch\n// after\nout, err := mem.Handle(ctx, tools.SearchInMemoryToolName, args) // use exported constants","handlingStrategy":"type-guard","validationCode":"knownTools := map[string]bool{\n    tools.SearchInMemoryToolName: true,\n    tools.StoreInMemoryToolName:  true,\n}\nif !knownTools[name] {\n    return fmt.Errorf(\"tool %q not registered for memory handler\", name)\n}","typeGuard":"func isMemoryTool(name string) bool {\n    switch name {\n    case tools.SearchInMemoryToolName, tools.StoreInMemoryToolName:\n        return true\n    }\n    return false\n}","tryCatchPattern":"out, err := handler.Handle(ctx, name, args)\nif err != nil && strings.HasPrefix(err.Error(), \"unknown tool:\") {\n    logger.Warnf(\"routing miss for tool %q, falling back to registry lookup\", name)\n    return registry.Dispatch(ctx, name, args)\n}","preventionTips":["Route tool calls through a registry keyed by the exported *ToolName constants.","Only expose registered tool definitions to the LLM so it cannot invent names.","Grep prompts/caches for old tool names after renaming a tool constant."],"tags":["tool-dispatch","unknown-tool","memory","agent"],"backgroundTag":"unknown-tool-name","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}