Tencent/WeKnora · error

tool not found: %s

Error message

tool not found: %s

What it means

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.

Source

Thrown at internal/agent/tools/registry.go:69

// RegisterTool adds a tool to the registry.
// If a tool with the same name is already registered, the existing one is kept
// (first-wins) to prevent tool execution hijacking via name collision (GHSA-67q9-58vj-32qx).
func (r *ToolRegistry) RegisterTool(tool types.Tool) {
	name := tool.Name()
	if _, exists := r.tools[name]; exists {
		logger.Warnf(context.Background(),
			"[ToolRegistry] Duplicate tool registration rejected: %s (first-wins policy)", name)
		return
	}
	r.tools[name] = tool
}

// GetTool retrieves a tool by name
func (r *ToolRegistry) GetTool(name string) (types.Tool, error) {
	tool, exists := r.tools[name]
	if !exists {
		return nil, fmt.Errorf("tool not found: %s", name)
	}
	return tool, nil
}

// ListTools returns all registered tool names sorted alphabetically.
// Sorting keeps the order stable across calls — Go map iteration is
// intentionally randomized.
func (r *ToolRegistry) ListTools() []string {
	names := make([]string, 0, len(r.tools))
	for name := range r.tools {
		names = append(names, name)
	}
	sort.Strings(names)
	return names
}

// GetFunctionDefinitions returns function definitions for all registered tools.
// The slice is sorted by tool name so the serialized payload sent to the LLM

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Verify the tool name spelling against registered tool names
  2. Register the expected tool before dispatch
  3. Check whether a duplicate registration was rejected by the first-wins policy
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/agent/tools/registry.go:69 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/d60e363c9c4f047a. Report an issue: GitHub.