ac4af582301a4e8a29245dbba767eba31334ddf9
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
5666cb0490 |
search MCP: web_search takes a count, 6 by default, 1 to 20 (treeman)
The web search MCP server's web_search always gave 6 results: searchHits was both what a search API (a plugin's included) was asked for and where its pages were cut. It now takes an optional count, described in its input schema (integer, minimum 1, maximum 20, default 6). A number or a number in a string is taken, floored; below 1 is held to 1, above 20 to 20 (Brave and Tavily take no more than 20); null or a non-number is the default 6. The tool's description is unchanged, and the web_search magpie offers models on vendor requests keeps its schema (no count). The count rides the search's context (withSearchCount/searchCount), so every backend reads it: plugin search APIs by key and signed-in (the count handed to the hook and the pages cut), Tavily max_results, Brave count, Exa numResults, Firecrawl limit, DeepSeek count, Volcengine Count, You.com count (all three routes), Yuanbao Search's Cnt (the fewest of 10/20/... that covers it), SearXNG (cut only), Kimi Code's limit, GLM's search MCP and Codex's backend search (cut only, neither takes a count), WorkBuddy (its client's 5 unless more than 6 is asked). A searcher model's search is prose and has no count. Run (mote): go test -run 'Search|Codex|Kimi|GLM|WorkBuddy|Plugin' ./internal/gateway ok; -race of the new tests and TestSearchMCP* ok; go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet of the package ok; gofmt -l empty. Broken by hand: searchCount ignoring the count went red in both new tests (plugin asked for 6, said 6, every vendor asked 6); withSearchCount without the clamp went red for 50, 0 and -3. Not tried: a real search API or plugin with count > 6; the full suite runs after the push. |
||
|
|
a1f7b8c13f |
plugin: gateway key limits are the Key limits plugin on the gateway's budget point (P3)
The last P3 point, after observer, router strategy, middleware and tool:
the budget point (internal/gwbudget). A plugin serves a Limiter while it
is on; the gateway asks gwbudget.Limiting before any request of a key held
to a limit goes to a provider (reserveFor: the chat APIs' keyLimited, the
search MCP server and the vision one). A request without a key, or of a
key with no limit, never asks it.
It fails closed. A key with a limit and no limiter served gets 503
gateway_key_limit_off, X-Should-Retry false, nothing sent, and a rejected
usage row. With none served, Limiting first asks the gateway's refresh
(pluginrt.Refresh, at most once a second, never from inside one), so a
limit set a moment ago turns the plugin on for the request that needs it.
A limit reached is the 429 gateway_key_limit with Retry-After and
X-Magpie-Limit-Reset, as before.
plugins/budget serves internal/budget's limiter (budget.Limiter). It is
Essential and in use while a gateway key has a limit, so it can only be
off while none has; a keys file that can't be read is an error, so it
stays on. KeepFresh watches the keys file too. What a key has used and
has left (/v1/magpie/limit, the Gateway page, the CLI) and budget.Append
stay in the core, so the ledger counts a key's use the same either way,
and the key editor's limit fields stay, since setting a limit is what
turns the plugin back on.
The builtins GUI test wheels to the Routing row as it did to Usage's: the
new row puts it below the fold in WebKit, where the page puts back a
scroll that isn't the reader's (scrollOnPurpose).
Run at this head (on origin/main
|