Skip to content

A broad skill search silently drops matches past the eighth #810

Closed

Description

What happens

src/tool/skill.ts handles a keyword query with:

const matched = searchSkills(params.query, candidates)   // limit defaults to 8
if (matched.length === 0) throw new Error(`No skills matched "${params.query}". ...`)
const listing = matched.map((skill) => `- **${skill.name}** (${skill.category}): ...`).join("\n")
return {
  output: `## Ranked skill matches\n\nNo skill instructions have been loaded. Load an applicable result by calling this tool with its exact name.\n\n${listing}`,
  ...
}

searchSkills(query, skills, limit = 8) in src/skill/search.ts:43,85 ends with .slice(0, limit), so the tool sees at most 8 — and the output carries no total and no hint that anything was dropped.

The category browse branch immediately below, which is the same kind of bounded list, is careful about this:

`${candidates.length} skills available. Showing ${matched.length} from offset ${params.offset ?? 0}.`
...(offset + matched.length < candidates.length ? ` Browse the next page with offset ${...}, or use a focused query.` : "")

Why it is wrong

A ranked list of 8 with no total reads as "these are the relevant skills". The 9th-best match is dropped from the end with no signal, and the model has no reason to try a narrower query or a different phrasing.

This is the "silently drops the end of a list" failure mode, and it is the common case: the bundled library is ~371 skills, so any broad capability query ("RNA", "statistics", "visualization") matches far more than 8.

Verified on this machine with the existing 43-skill fixture — a query: "biology" returns exactly 8 of 43 matches, with nothing in the output indicating the other 35.

Repro

const broad = await tool.execute({ query: "biology" }, context())
broad.metadata.matches  // 8 entries
broad.output            // "...Load an applicable result by calling this tool with its exact name.\n\n- **biology-00**..."
                       // no total, no hint

Suggested fix

Rank the whole candidate set and slice in the tool, so the count is available:

const ranked = searchSkills(params.query, candidates, candidates.length)
const matched = ranked.slice(0, 8)
const dropped = ranked.length - matched.length

then append Showing ${matched.length} of ${ranked.length} matches; narrow the query to see the rest. to the instruction sentence, mirroring the category branch.

The test is added to the existing 43-skill case in test/skill/discovery.test.ts, and also asserts a query that fits inside the cap does not get the note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions