litellm/.github/workflows
Mateo Wang ef7bea124e
feat(mcp): re-rank mcp_tool_search results with a rerank model (#55799)
* feat(mcp): re-rank mcp_tool_search results with a rerank model

Adds an optional `litellm_settings.mcp_tool_search.rerank_model`, a model_name from model_list.
When it is set, the keyword or embedding stage keeps up to 50 candidates and one /rerank call
through the router re-orders them before top_k is applied. The call runs the same pre-call hooks
as /rerank and is billed to the calling key. A provider error, timeout or invalid answer keeps
the base order. Rate-limit and guardrail refusals still reach the caller.

The Admin UI settings form carries the field so a save does not drop it.

* fix(mcp): resolve the caller's guardrails before the tool search rerank call

The rerank sub-call now attaches key, team, project and policy guardrails to its request
metadata the same way /rerank does, so guardrails assigned to the caller run on it.

* fix(mcp): forward the caller's model region on the tool search rerank call

The rerank sub-call now passes allowed_model_region to the router when the caller has one,
as the /rerank request setup does, so region-restricted keys keep their routing checks.

* refactor(mcp): send the tool search rerank call through the proxy's /rerank routing

The rerank sub-call now goes through route_request like /rerank, so team model aliases and blocked models apply, and a rerank_model missing from model_list keeps the base order

* fix(mcp): check the caller's model access before the tool search rerank call

A key or team whose model allowlist or per-model budget excludes the rerank model now keeps the keyword or embedding order, with no rerank call and no spend, using the same caller checks compaction's sub-call runs

* fix(mcp): count the tool search rerank call against the caller's per-model budgets

The rerank sub-call now carries the key, team, user, team member and end user model budgets in its metadata, so the budget tracker charges its spend and the caller gate refuses the next call once a budget is spent

* fix(mcp): keep the base order on every rerank failure, log rerank with caller tags and redaction opt-in, rerank the whole catalog in keyword mode, warn on an unroutable rerank_model

* fix(mcp): send inherited_tags with the tool search rerank so key and team tag rules route it like /rerank

* fix(mcp): free the key's rate-limit slot and keep the base order when any guardrail blocks the tool search rerank

* fix(mcp): bound the tool search rerank call, warn on a non-rerank rerank_model, and log it to the key's and team's callbacks

A failed rerank after the pre-call hooks now reports the dict they returned, like /rerank, so a masked query stays masked in failure logs

* test(proxy): keep the settings endpoint tests in their original layout

The previous commit reformatted the whole file. This keeps only the new rerank_model mode warning test

* fix(mcp): bound every tool search rerank step by one timeout, free its rate-limit slot on cancel, and check sub-call budgets by the sub-call's model

* fix(mcp): run each tool search rerank step in the calling task so the failure hook frees the rate-limit slot on Python 3.10 and 3.11

* fix(mcp): skip the rerank_model mode warning for names only a wildcard, default deployment or pass-through matches

---------

Co-authored-by: Xytronix <32957125+Xytronix@users.noreply.github.com>
2026-12-04 16:25:01 -08:00
..
auto-close-duplicates.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
check-schema-sync.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
codeql.yml ci: fit the pull request gate into five minutes (#52660) 2026-11-18 14:41:04 -08:00
codspeed.yml ci: fit the pull request gate into five minutes (#52660) 2026-11-18 14:41:04 -08:00
compat-matrix-image.yml feat(docker)!: one shipped image and one entrypoint beside the Dockerfile (#43332) 2026-11-10 18:32:16 -08:00
conventional-commits.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
cost-map-guard.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
cost-map-pins-recheck.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
create-rc-branch.yml ci: cut the weekly rc branch on Monday 3am PT instead of Friday (#49472) 2026-10-31 12:32:23 -07:00
create-release-branch.yml ci(release): create stable/X.Y.x line branch on X.Y.0 tags (#29457) 2026-06-01 15:56:34 -07:00
e2e_record_replay.yml ci(e2e): install e2e-dev for record and replay and look up the bundle by name (#55930) 2026-12-03 18:06:25 +00:00
fips-scan.yml build(docker): build the FIPS image from the main Dockerfile with FLAVOR=fips (#54994) 2026-11-30 09:47:47 -08:00
guard-fork-dependencies.yml chore: move workspace packages under litellm (#51000) 2026-11-12 04:19:57 +00:00
image-scan.yml ci: fit the pull request gate into five minutes (#52660) 2026-11-18 14:41:04 -08:00
interactions-spec-canary.yml feat(interactions): forward continuation_token and type requires_continuation so callers can resume a long decode (#50151) 2026-11-05 15:38:44 -08:00
issue-keyword-labeler.yml chore: fixes 2026-04-05 01:30:57 -07:00
issue_fixed_comment.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
issue_label_claude_code.yml ci(issue-classifier): name every workflow, script and job after the issue it works on 2026-09-18 11:37:55 -07:00
issue_label_sync.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
keep-handwritten-description.yml ci: restore a PR's handwritten description when an edit resets it to the placeholder (#53486) 2026-11-21 16:50:40 -08:00
linear-release.yml ci: sync the weekly release cycle with Linear releases (#43636) 2026-09-28 17:00:56 -07:00
mutation-test.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
oss-pr-file-cap.yml ci: cap outside contributor PRs at 20 changed files (#56165) 2026-12-04 03:08:13 +00:00
osv-scan.yml chore: move ui and vscode-extension under litellm and delete docs (#50992) 2026-11-12 04:19:57 +00:00
publish-lint-base-counts.yml refactor(rust): rename the compiled module _native to _rust (#55198) 2026-12-01 07:08:38 -08:00
root-entry-limit.yml ci(lint): run the fast lint checks on pull requests again without compiling Rust (#53421) 2026-11-21 14:17:30 -08:00
scorecard.yml chore: fixes 2026-04-05 01:30:57 -07:00
spend-logs-guard.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
stale.yml chore: fixes 2026-04-05 01:30:57 -07:00
sync-schema.yml chore: move scripts and runtime sources under litellm (#51006) 2026-11-12 04:19:57 +00:00
test-e2e-redis-chaos.yml test(e2e): rename load to perf and consolidate the opt-in into E2E_PERF_TESTS (#46077) 2026-10-12 13:54:03 -07:00
test-integration.yml ci(integration): run integration and MCP dependency resolution three times a day (#54749) 2026-11-26 15:16:22 -08:00
test-linting.yml ci: start fewer jobs per pull request (#54757) 2026-11-26 18:21:09 -08:00
test-mcp-dependency-resolution.yml ci(integration): run integration and MCP dependency resolution three times a day (#54749) 2026-11-26 15:16:22 -08:00
test-merge-smoke.yml refactor(rust): rename the compiled module _native to _rust (#55198) 2026-12-01 07:08:38 -08:00
test-rust-db.yml ci(rust): run LiteLLM Rust DB on pushes to main only and cover release-line PRs (#52609) 2026-11-18 17:44:13 -08:00
test-rust.yml ci(rust): run the feature combination tests in their own job (#55027) 2026-12-03 21:36:10 +00:00
test-terraform-modules.yml chore: move deployment sources under litellm/deploy (#50981) 2026-11-12 04:19:56 +00:00
test-terraform-provider.yml feat(proxy): send gateway model calls to Lens as traces when the Lens store is connected (#53042) 2026-11-20 10:12:08 -08:00
test-unit.yml feat(mcp): re-rank mcp_tool_search results with a rerank model (#55799) 2026-12-04 16:25:01 -08:00
test-vscode-extension.yml chore: move ui and vscode-extension under litellm and delete docs (#50992) 2026-11-12 04:19:57 +00:00
zizmor.yml ci: run zizmor with --no-ignores and move the spend logs and cost map guards to pull_request (#48947) 2026-10-28 17:44:48 -07:00