Files
magpie/docs
yetone 7300be4d01 gateway: find_tools says no tool was found instead of handing over near names
sahuaja3669 on X (tweet 2122928458355319211), on the on-demand router:
it shouldn't pad its answer with tools of a near name that do something
else, and it should say plainly when nothing was found.

Before, find_tools counted any query word found as a substring of a
tool's name or description, stop words and single letters included. "a"
is in nearly every name, so "send an email" against GitHub, filesystem,
Linear, magpie-image and magpie-browser gave five tools in full
(search_code, read_file, write_file, ...) as matches, with nothing saying
they were weak; a query nothing matched did say so.

Now find_tools matches on the query's key words (stop words such as a,
the, to, my left out), each a whole word of the name or description or
the start of one at four letters or more (open/opens, issue/issues; a
non-ASCII word anywhere, as before). A tool is a match only when the
query is its name, or it has two thirds of the key words, one in its
name unless it has them all. When none clears that, the answer says no
tool was found and not to call one that only sounds close, and names
each server with its tool count and up to 8 of its tool names, as what
there is rather than as matches. call_tool's "close to it" for an
unknown name keeps a looser rule (a key word shared with the name,
hubNear), so create_isue still points to create_issue. Cheap and
deterministic: word lists, no model, no index.

The cost: a query in other words than the tool's ("draw an image of a
cat" for generate_image) now finds nothing, and the model reads
generate_image from the server list in the answer, and from find_tools'
description, which already names each server's tools.

Test: TestHubFindNothingClose, on real descriptions from
github-mcp-server, the reference filesystem server, Linear's, and
magpie-image's and magpie-browser's own. Red on the old
hub_ondemand.go: "send an email" matched eight tools or more, five in full.
docs/subsystems/mcp-router.md updated.

Run:
- full go test ./... -count=1 -timeout 45m on mote at 5c32b285d (on
  48fffb60c): every package ok, internal/gateway 1392s.
- full go test ./... -count=1 -timeout 45m on mica at 1acbfcc23 (on
  3e66d25d8), mote over its load: 100 packages ok, three red, none in
  code this touches: internal/dirent's watch tests (red on mica at
  3e66d25d8 alone too, ok on mote; #7031), internal/sessions
  TestWSLStoppedSinceNotOpened (internal/sessions doesn't import
  gateway; red 1 of 4 on mica at 3e66d25d8 alone, ok on mote; filed
  #7089), internal/gateway TestSearchQueueKeepsCodexAlive/progress (ok
  3 of 3 alone; filed #7090).
- at the pushed head 22647c27f (on e199eb9c7): go test ./internal/gateway
  -count=1 -timeout 45m on mica ok (1306s); go vet ./internal/gateway
  for darwin, linux and windows ok; gofmt -l clean.
- rebased onto d2fa7d8d7 to push (four commits: sessions, library, and
  d74754970's system-message placement in gateway, none in the hub);
  there go test ./internal/gateway -run 'Hub|MCP|Search|Message|System'
  ok on mica, go vet ok. 65c9a2e41 there addresses #7089's WSL wait.
Not tried: a real agent driving find_tools against a live router.
2026-11-18 18:58:55 +08:00
..