fix: skill retrieval boosts on tag substrings (e.g. 'ai' tag for any 'email' query) (#1406)

* fix: match skill tags as whole tokens, not substrings, in retrieval

* test: skill tag matching uses whole tokens, not substrings

* test: give skill fixtures status=published so they reach the scoring path
This commit is contained in:
Afonso Coutinho
2026-06-03 06:24:11 +01:00
committed by GitHub
parent 49bf73b228
commit fb8a744cae
2 changed files with 40 additions and 1 deletions

View File

@@ -650,7 +650,10 @@ class SkillsManager:
])
score = _jaccard(query_tokens, _tokenize(text))
for tag in sk.get("tags", []) or []:
if tag and tag in query.lower():
# Match tags as whole tokens, not substrings: `tag in query`
# boosted e.g. a "ai" tag for any query containing "email".
tag_tokens = _tokenize(tag)
if tag_tokens and tag_tokens <= query_tokens:
score = max(score, 0.3) * 1.3
if query.lower() in (sk.get("description") or "").lower():
score = max(score, 0.6)