Skip to content

fix: search tools not found when using per-request routers#19818

Merged
yuneng-jiang merged 1 commit intoBerriAI:litellm_router_search_fixfrom
Quentin-M:search_tools_fix
Jan 31, 2026
Merged

fix: search tools not found when using per-request routers#19818
yuneng-jiang merged 1 commit intoBerriAI:litellm_router_search_fixfrom
Quentin-M:search_tools_fix

Conversation

@Quentin-M
Copy link
Contributor

Root Cause:

When API keys or teams have router_settings configured, the proxy creates per-request Router instances from user_config. These new routers were missing search_tools from the main router, causing "search tool not found" errors despite search_tools being configured.

The Fix:

  1. common_request_processing.py (lines 554-556): Pass search_tools from main router to user_config so per-request routers inherit them

  2. proxy_server.py (line 3171): Remove if len(_model_list) > 0 check to allow router creation with empty model list (needed for search-tools-only use case)

  3. proxy_server.py (line 746): Remove redundant search_tools loading code (already handled by _init_search_tools_in_db() called during startup)

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

🐛 Bug Fix

**Root Cause:**

When API keys or teams have router_settings configured, the proxy creates
per-request Router instances from user_config. These new routers were missing
search_tools from the main router, causing "search tool not found" errors despite
search_tools being configured.

**The Fix:**
1. **common_request_processing.py (lines 554-556):** Pass search_tools from main
   router to user_config so per-request routers inherit them

2. **proxy_server.py (line 3171):** Remove `if len(_model_list) > 0` check to
   allow router creation with empty model list (needed for search-tools-only use case)

3. **proxy_server.py (line 746):** Remove redundant search_tools loading code
   (already handled by _init_search_tools_in_db() called during startup)
@vercel
Copy link

vercel bot commented Jan 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
litellm Ready Ready Preview, Comment Jan 26, 2026 11:11pm

Request Review

@CLAassistant
Copy link

CLAassistant commented Jan 26, 2026

CLA assistant check
All committers have signed the CLA.

@krrishdholakia
Copy link
Member

The approach of creating a new router instance by key/team seems brittle (and also has poor performance as it initializes a new client on each request).

@yuneng-jiang can you please take over this PR and come up with a better approach to team/key settings, where they just override global values instead of creating a separate instance per key/team?

@yuneng-jiang yuneng-jiang changed the base branch from main to litellm_router_search_fix January 31, 2026 23:44
@yuneng-jiang yuneng-jiang merged commit 93383d0 into BerriAI:litellm_router_search_fix Jan 31, 2026
4 of 7 checks passed
shin-bot-litellm added a commit that referenced this pull request Feb 7, 2026
Previously, PR #19818 (via #20205) removed the model_list check entirely,
causing Router to be created even with no models AND no search_tools.

This fix adds back a conditional check that creates the Router only when:
- There are models to route, OR
- There are search_tools configured

This preserves the PR #19818 goal (search-tools-only deployments) while
avoiding unnecessary Router creation when there's nothing to route.

Fixes test_add_and_delete_deployments[0-None]
ishaan-jaff pushed a commit that referenced this pull request Feb 7, 2026
)

Previously, PR #19818 (via #20205) removed the model_list check entirely,
causing Router to be created even with no models AND no search_tools.

This fix adds back a conditional check that creates the Router only when:
- There are models to route, OR
- There are search_tools configured

This preserves the PR #19818 goal (search-tools-only deployments) while
avoiding unnecessary Router creation when there's nothing to route.

Fixes test_add_and_delete_deployments[0-None]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants