Repository navigation
fix(agent): match tool names across a trailing plural s - #1574
Open
Conversation
Contributor
Author
Self-Review (
|
TheGreatAxios
requested changes
Oct 27, 2026
TheGreatAxios
left a comment
Collaborator
There was a problem hiding this comment.
Review · Request changes
Folds one trailing plural "s" on name tokens so a singular query can match a plural tool name and the reverse, with an exact spelling still scoring higher.
Findings
src/agent/lexical-rank.ts:24—FOLDED_NAME_TOKEN_SCOREis 2.5 so a folded name hit stays under the exact token score of 3. That clearsTOOL_SEARCH_SCORE_RATIO(0.75) for a two-word query whose top is 6, which is what the comment next to the constant describes. It does not clear the same cut for a one-word plural query.name.includes(rawQuery)adds 1 on top of the exact token score, solist_issuesscores 4 for"issues"and the floor is 3.get_issueandsave_issueonly fold, so they score 2.5 andcreateToolIndex(...).search("issues", 20)returns just["mcp__linear__list_issues"]. The other direction still works:search("issue", 20)keepslist_issuesat 3.5. No weight strictly under 3 can clear a floor of 3, and 3 would tiesearch("issue")(both names also take the substring point), which drops "exact spelling outranks folded." One way out is to stop the one-token raw-substring bonus from setting that floor — a one-word query is already paid for by the token score — so the top stays 3, 2.5 still clears0.75 * 3, and the exact token still ranks first. The new tests never callsearch("issues").
Checked with bun -e against a Linear-shaped catalog (list_issues, get_issue, save_issue) in the PR worktree: scores 4 / 2.5 / 2.5 for "issues", and only list_issues returned. bun test src/agent/lexical-rank.test.ts src/agent/tool-search.test.ts was 99 pass, 0 fail; those tests do not cover this query.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mcp__linear__list_issuesand "issues" findsget_issue. An exact-spelling name match outranks a folded one, so "list issues" and "linear issues" ranklist_issuesfirst in any catalog order. Description and parameter tokens keep exact matching.list_issuestied for 5th at the result limit, so catalog order decides whether it lands 5th or 6th. Without folding it scores below the cutoff and never returns. The tie sits at the result limit, tie order is outside this issue's scope, and the result is a strict improvement over a miss.mainby hand.Verification
bun run check(lint, typecheck, dead exports, build, test) exits 0 on this branch: 9528 pass, 0 fail.search-scorer-parity.test.ts, pass with no change to their expected order; the diff adds tests and changes no existing assertion.Fixes CL-11435