Skip to content

[REFACTOR][llm_backend][Remove litellm and make RouteHub the default and only model-call backend] - #2789

Closed
ayaangazali wants to merge 2 commits into
kyegomez:masterfrom
ayaangazali:pr/routehub-only-backend
Closed

ayaangazali wants to merge 2 commits into
kyegomez:masterfrom
ayaangazali:pr/routehub-only-backend

Conversation

@ayaangazali

@ayaangazali ayaangazali commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What is wrong

llm_backend picks the model-call library at import time (RouteHub when installed, litellm otherwise), and litellm is the required dependency while RouteHub is optional behind swarms[fast]. Two backends means every model-call behaviour has to hold on both.

What this changes

RouteHub becomes the only model-call backend, installed by default:

  • Dependencies: litellm removed from pyproject.toml and requirements.txt; routehub[fast]>=0.2.0 becomes a required dependency and drops out of the fast extra. tqdm is now declared: agent_loader imports it and it used to arrive only through litellm, so a fresh install without it failed on import swarms.
  • swarms/utils/llm_backend.py: the litellm branch, the BACKENDS tuple, the install hints and select_backend are gone; backend_module() always imports RouteHub. A leftover SWARMS_LLM_BACKEND=litellm warns once instead of switching; other values are ignored. Lazy import and the __getattr__ passthrough are unchanged.
  • swarms/utils/litellm_wrapper.py: the branch that wrote module-level settings onto litellm and the RouteHub-only guard on the vision-catalog check collapse to their RouteHub paths.
  • Text that named the old default: CLI strings and docstrings (cli/main.py, cli/models.py, cli/tips.py, cli/utils.py, tree_of_thoughts.py), the auto-builder prompt's model-string guidance, README.md, CLAUDE.md, SKILL.md and .env.example (SWARMS_LLM_BACKEND entry removed). cli/models.py keeps reading the litellm_provider key, because RouteHub returns the same model-info shape.
  • Tests: tests/utils/test_llm_backend.py drops the backend-selection suite for RouteHub-only coverage, including the leftover-litellm warning.

Verified

RouteHub 0.2.0 exposes every name the package reads (completion, acompletion, embedding, model_list, get_model_info, get_max_tokens, encode, the supports_* checks, provider exceptions). Full offline suite, forced-RouteHub on master vs this branch: identical results (249 failed / 2135 passed both sides: the same pre-existing live-LLM-without-key failures the unit suite carries today).

Deliberately not in this PR

The litellm_wrapper module and LiteLLM class rename to a backend-neutral name (with a one-release deprecated alias) is pure churn across ~55 files with no behaviour change, so it gets its own PR, as does the sweep of the 60 example files. git grep -i litellm still names the wrapper, which the acceptance in #2781 anticipates staging.

Closes #2781

@ayaangazali
ayaangazali requested a review from kyegomez as a code owner October 21, 2026 19:19
Copilot AI balanced review requested due to automatic review settings October 21, 2026 19:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests prompts utils agents labels Oct 21, 2026
agent_loader imports tqdm, but swarms never declared it; it arrived
through litellm. With litellm removed, a fresh install fails on
"import swarms" with ModuleNotFoundError: No module named 'tqdm',
which is why every test module errored at collection in CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the ai-generated Opened by or written with an AI coding agent label Oct 21, 2026
from typing import Any

BACKENDS = ("routehub", "litellm")
from loguru import logger

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change for this one. loguru is a declared runtime dependency (pyproject.toml and requirements.txt), and 45 modules under swarms/ on master already import it the same way. Pyre's environment does not install the package's dependencies, so it cannot resolve the import anywhere; it reports it here only because this PR added the line (the same alert was answered on #2451).

The test job does install dependencies and imports this module: all 9 tests in tests/utils/test_llm_backend.py pass, and the job's 246 failures and 7 errors are the same set as master's latest run on 6967b7d, all from tests that need a live OPENAI_API_KEY.

@kyegomez

Copy link
Copy Markdown
Owner

i assigned this to myself, if you didn't see

@kyegomez kyegomez closed this Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents ai-generated Opened by or written with an AI coding agent documentation Improvements or additions to documentation prompts tests utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR][llm_backend][Remove litellm and make RouteHub the default and only model-call backend]

4 participants