vxcontrol/pentagi · error

unknown tool: %s

Error message

unknown tool: %s

What it means

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.

Source

Thrown at backend/pkg/tools/search.go:384

			}
			_, _ = s.vslp.PutLog(
				ctx,
				agentCtx.ParentAgentType,
				agentCtx.CurrentAgentType,
				filtersData,
				action.Question,
				database.VecstoreActionTypeStore,
				action.Answer,
				s.taskID,
				s.subtaskID,
			)
		}

		return "answer for question stored successfully", nil

	default:
		logger.Error("unknown tool")
		return "", fmt.Errorf("unknown tool: %s", name)
	}
}

func (s *search) IsAvailable() bool {
	return s.store != nil
}

View on GitHub (pinned to ea665308ba)

Solutions

  1. 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.
  2. Tighten the tool schema/prompt so only implemented action names are advertised to the model.
  3. If the name is a hallucination, retry the request with a stronger model or add explicit few-shot examples of valid action names.
  4. Normalize the incoming name (trim/case-fold) before dispatch if providers vary formatting.

Example fix

// before
default:
    return "", fmt.Errorf("unknown tool: %s", name)
// after
default:
    return "", fmt.Errorf("unknown tool: %q; valid actions: %v", name, []string{"question", "store_answer"})
Defensive patterns

Strategy: validation

Validate before calling

var validActions = map[string]bool{"question": true, "store_answer": true}
if !validActions[name] {
    return "", fmt.Errorf("unknown tool: %s", name)
}

Try / catch

result, err := searchTool.Handle(ctx, req)
if err != nil {
    var uerr *UnknownToolError
    if errors.As(err, &uerr) {
        // re-prompt the LLM with the list of valid actions
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01). Data as JSON: /api/errors/11d5c941c4ee86df. Report an issue: GitHub.