Repository navigation
Review mirror: preserve MCP tool-search prompt cache (#16539) - #296
wasimysaid wants to merge 10 commits into
Conversation
…ation mcp_tool_search injected the matched tool schemas into the declared tools array mid-turn. The chat template renders tools at the top of the prompt, so the next continuation diverged from the first tokens and llama-server re-evaluated the whole conversation; on hybrid/recurrent models without a checkpoint at the divergence that is a full prefill (unslothai#16538), and a discovered-but-unused tool dropped from the next turn's listing repeated the storm on every later search. The search result now carries the full schemas it already budgets with _MCP_TOOL_LOAD_SHARE, and the controller only opens its call gate for the found catalog names, leaving the declared tools - and the cached prompt prefix - untouched. Tools a thread runs are still recorded and listed on its later turns. Refs unslothai#16538
|
@codex review |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 860a824061
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b7afe4c1bb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7422d5b1f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d4293d2c0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Fixes #16538. Keep searched MCP schemas out of the local model’s cached prompt declaration and return them in tool results. For llama.cpp, supply discovered schemas to its decoding grammar separately from the template’s tools. External providers retain normal tool declarations because they cannot separate the two. Search admits only complete schemas within the response budget, without charging rejected matches against smaller tools. Deferred calls retain the existing schema-identifier filtering and argument coercion. Continues Shreesh-Sree’s #16539, preserving the original commits. That PR and its source fork became unavailable during review. Includes fixes for four Codex findings from [the review mirror](wasimysaid#296), plus the external-provider compatibility regression. Live validation: - Real ComfyMCP discovery: 23 tools plus the resource tool. Main expands declarations from 5 to 7; the local prompt declaration stays at 5 after the fix. - Qwen3.5-0.8B/llama.cpp b11985 controlled replay: 1,616 cached tokens versus 1,104 on main. This verifies the mechanism, not the reported 17× timing or Windows hardware. - Qwen3-8B-Q4_K_M/b11985: the original stable declaration repeats the search; the separated grammar emits the discovered native call (`mcp__demo__ping`, `n=7`). `/apply-template` confirms byte-identical rendered prompts. MCP/controller/external-loop tests: 317 passed. The updated llama-loop regression and seven llama MCP tests pass. Pre-commit passes. Regression cases fail on their respective baselines. The broader backend run was interrupted after stalling with 415 tests passed; it is not a full-suite pass. [Final Codex review](wasimysaid#296 (comment)) found no major issues at `d9570c4ffa`. --------- Co-authored-by: Shreesh-Sree <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Han <[email protected]>
Fixes unslothai#16538. Keep searched MCP schemas out of the local model’s cached prompt declaration and return them in tool results. For llama.cpp, supply discovered schemas to its decoding grammar separately from the template’s tools. External providers retain normal tool declarations because they cannot separate the two.
Search admits only complete schemas within the response budget, without charging rejected matches against smaller tools. Deferred calls retain the existing schema-identifier filtering and argument coercion.
Continues Shreesh-Sree’s unslothai#16539, preserving the original commits. That PR and its source fork became unavailable during review. Includes fixes for four Codex findings from the review mirror, plus the external-provider compatibility regression.
Live validation:
mcp__demo__ping,n=7)./apply-templateconfirms byte-identical rendered prompts.MCP/controller/external-loop tests: 317 passed. The updated llama-loop regression and seven llama MCP tests pass. Pre-commit passes. Regression cases fail on their respective baselines. The broader backend run was interrupted after stalling with 415 tests passed; it is not a full-suite pass.
Final Codex review found no major issues at
d9570c4ffa.