Repository navigation
perf(mcp): add opt-in hot/cold tool discovery - #9046
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The PR appears safe to merge; the earlier discovery reply-limit issue is fixed. SummaryAdds opt-in hot/cold tool discovery while keeping full advertising as the default.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Initial hot tool catalog"] --> B["Call discover_tools"]
B --> C{"All names in scope?"}
C -- No --> D["Return bounded error; load nothing"]
C -- Yes --> E{"Both reply forms fit?"}
E -- No --> D
E -- Yes --> F["Enable original named tools"]
F --> G["Notify once if visibility changed"]
G --> H["Client refreshes tools/list"]
Reviews (2) · Last reviewed commit: "fix(mcp): bound discovery replies before..." · Reviewed by Greptile |
Summary
Add opt-in
REA_MCP_TOOL_CATALOG_PROFILE=hot-cold: advertise five session/Evidence tools plusdiscover_tools, then load original named tools on demand. Full advertisement remains the default because client support and whole-task costs vary.Problem and expected behavior
The 235-tool
tools/listresult is 4,035,856 UTF-8 bytes. Hot/cold starts with 6 tools / 738,763 bytes and keeps the in-scope inventory discoverable. The default catalog is byte-identical to pinned main808491685.Change and scope
Contract and boundary impact
discover_tools({query:"sqlite",limit:1})loadsinspect_sqlite_database; the next call uses that original tool. Discovery performs no analysis and provides no generic execution gateway.Codex 0.165.0 needs
features.mcp_tool_list_changed=true. A canary reader was unavailable by default, callable with refresh enabled, and remained blocked bydisabled_toolswith refresh enabled. Other harnesses remain unverified.Evidence and regression coverage
Real Codex 0.165.0, requested alias
gpt-6.1-sol/ low / code-mode host (resolved model identity unreported), serial trials against immutable builds. Artifacts:[email protected]and public Chinook SQLite. Independent source/SQLite oracles, returned Evidence IDs, unchanged target bytes, cleanup and resources passed 42/42 task trials. Two additional artifact pilots also passed. Rejected MCP calls, discovery misses and recovery costs remain included.Final revision
98e17d7a1: full catalog → hot/cold, full output schemas, matching prompts, means of 2 fresh agent/server runs per cell; peak is the largest per-trial cgroup peak. Input includes cache; uncached = reported input minus cached input.Final repeats show higher SQLite input and essentially equal combined-task input. Earlier experiments (12 initial-reply trials and 22 trials on
b762f9b, including compact/full schemas and discovery-guidance diagnostics) showed substantial variance: full-output semver exports averaged 763,847 → 573,432 input and package/SQLite 367,739 → 261,413; compact-output package/SQLite increased 227,678 → 250,410. The budget fix preserves normal discovery replies byte for byte; differences across repeats demonstrate agent/cache variability. Initial Codex input stayed ~11.4K because its host already defers tool access.A separate three-hot-tool prototype reduced upfront exposure further but used 104,130 SQLite input tokens in its pilot; the final curated hot set is retained. These observations support an explicit loading option and further evaluation, with no general token-saving claim.
OS caches were warm; remote caching and agent paths varied. Counters cover the local process family at payload exit, including charged file cache; remote inference is unmeasured. Limits: 1 CPU, 4 GiB hard / 3 GiB early stop, no swap. No stops/OOM; cleanup verified. Raw transcripts/hashes/receipts remain local; no experiment reports or data are added.
Validation performed
python3 scripts/run-python-tests.py --analysis-efficiency: 102 passed.npm run check:fast,npm run docs:check,git diff --check: passed; relevant checks repeated after the reply-budget fix.Compatibility, safety, and release
Additive opt-in MCP profile. Real providers exercised: static JavaScript and SQLite; native deep providers and other agent clients were not exercised. Product docs are updated. The automatic reply-limit finding is fixed and resolved; Codex GitHub review was unavailable due repository review quota. No manual review request or retrigger was sent.
Author readiness
Human owner: @gensokyo-dev
Before merge
Required CI passed on
98e17d7a1; the actionable automatic finding is fixed/resolved and the automatic Greptile re-review is 5/5. This follows the catalog measurement work in #9035.