mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
Follow-up to #11440 for the latest comment on #11331. Problem: the ranker scored a tool as one bag of words. A query term in the tool's name counted like a mention in its description, and the server's instructions were copied into every tool's text, which lengthened it and lowered its score. Models often add words to a tool name, so `peekaboo app` ranked `mcp__peekaboo__app` 14th: other peekaboo tools mention "app" in shorter descriptions, and its own description says "applications". Fix: `Bm25Ranker` scores three fields separately: - name: a query term in the name counts 3x its IDF; the description part of BM25 is at most 2.2x, so a name match beats any number of description mentions; - description and schema text: BM25 as before, length-normalized on this field only; - namespace name, description, and instructions: 0.5x IDF per matching term, without length normalization. A tool whose whole local name (last `__` segment) is in the query gets a bonus worth one more match of every query term, so it mostly wins (`peekaboo app`, `describe app`, `read thread_read state`). A query that is exactly a tool's name still ranks it first (#11440). Applies to `tool_search` and codemode `searchTools()`. Not included: the comment's second point (loading a deferred tool on a direct call instead of `Tool X not found`). That error comes from `prepareToolCall` in `packages/agent`, which has no hook for unknown tools; it needs an agent-loop API change. |
||
|---|---|---|
| .. | ||
| bun | ||
| cli | ||
| core | ||
| experimental | ||
| extensions | ||
| modes | ||
| utils | ||
| cli.ts | ||
| config.ts | ||
| index.ts | ||
| main.ts | ||
| migrations.ts | ||
| package-manager-cli.ts | ||
| rpc-entry.ts | ||