Class KeywordSkillResolver

java.lang.Object
com.tnsai.skills.KeywordSkillResolver
All Implemented Interfaces:
SkillResolver

public final class KeywordSkillResolver extends Object implements SkillResolver
Cheap word-overlap SkillResolver — scores each candidate by how many of the user-message tokens occur in its name, description, and whenToUse text (TNS-289).

Default resolver in the framework. Adds zero round-trip cost and is good enough when skill descriptions are written with trigger phrases in mind. Operators wanting semantic matching plug in LLMSkillResolver or a custom embedding-based resolver via the SkillResolver SPI.

Scoring

Per candidate skill, every distinct word in userMessage that occurs in the skill's combined searchable text contributes one point. Field weights:
  • name matches count 3× (a name match is the strongest signal)
  • whenToUse matches count 2× (authored explicitly to capture intent)
  • description matches count 1×
Stop-words ("the", "a", "is", …) are filtered before scoring so common filler doesn't dominate.

Skills that score zero are excluded — surfacing irrelevant candidates would dilute the LLM's prompt budget.

Since:
0.10.0 (TNS-289)
  • Constructor Details

    • KeywordSkillResolver

      public KeywordSkillResolver()
  • Method Details

    • resolve

      public List<Skill> resolve(String userMessage, List<Skill> candidates, int limit)
      Description copied from interface: SkillResolver
      Pick the limit skills most relevant to userMessage. Returned list is ordered most-relevant-first; size is at most limit; an empty list is valid output (no skill matched the threshold).
      Specified by:
      resolve in interface SkillResolver
      Parameters:
      userMessage - the latest user turn
      candidates - the full set of registered skills (caller typically passes SkillStore.list())
      limit - maximum candidates to return; resolvers MUST not exceed this