Skip to content

[URGENT] fix: upgrade LiteLLM to 1.108.25 so tool-calling agent runs work - #9

Open
svngoku wants to merge 1 commit into
masterfrom
fix/litellm-tool-call-mcp-import
Open

svngoku wants to merge 1 commit into
masterfrom
fix/litellm-tool-call-mcp-import

Conversation

@svngoku

@svngoku svngoku commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Urgent: on master, every tool-calling completion fails with an ImportError before reaching the model provider. That covers the default agentic-internet run/chat path (ToolCallingAgent, reproduced live) and, through the same code path, multi-model workers built as ToolCallingAgent (not run live). This PR restores those runs with a one-package lockfile change. A 5-token completion without tools did not raise in testing; CodeAgent paths were not separately tested.

Related: model alias refresh in #10, which can merge independently and is live-verified together with this fix.

Summary

LiteLLM 1.108.3 imports its proxy MCP gateway on every completion() that passes tools, which every ToolCallingAgent step does. That module needs mcp.types.CacheableResult, which only exists in mcp>=2.3. This project locks mcp 1.23.2 for smolagents/mcpadapt, so the import fails:

agentic-internet run "..."
  ToolCallingAgent.run
    LiteLLMModel.generate(tools=[...])
      litellm.completion(tools=[...])                          # litellm/main.py
        import litellm.responses.mcp.chat_completions_handler
          import litellm.proxy._experimental.mcp_server.catalog
-           from mcp.types import CacheableResult              # ImportError on mcp 1.23.2

LiteLLM 1.108.25, on the same LTS line Plan 005 chose, adds a guard, may_name_litellm_mcp_gateway(tools), so the gateway is only imported when the tools may reference it:

 # uv.lock: the only package that changes
 name = "litellm"
-version = "1.108.3"
+version = "1.108.25"

Changes:

  • uv.lock: LiteLLM 1.108.3 → 1.108.25. No other package changes; mcp stays at 1.23.2.
  • tests/test_litellm_tool_calls.py: 2 offline regression tests using LiteLLM's mock_response (no network, no key). One covers a direct litellm.completion(tools=...) call, the other the smolagents.LiteLLMModel.generate(tools_to_call_from=...) path agents use.
  • docs/PLANS.md: dependency note next to the Plan 005 entry.

CI did not catch this because unit tests mock the model and no CI step makes a tool-calling completion. The new tests close that gap.

Evidence

  • Before (master, LiteLLM 1.108.3):
    • agentic-internet run "..." --model deepseek-v4.1-flash fails at step 1 with cannot import name 'CacheableResult' from 'mcp.types'.
    • The new tests fail with the same ImportError: 2 failed.
  • After (this branch, LiteLLM 1.108.25):
    • The new tests pass: 2 passed.
    • Full suite: 252 passed, 1 skipped (master: 250 + 1). Ruff, ruff format, mypy (30 files), uv lock --check, and golden principles are clean.
    • Live CLI run with LiteLLM 1.108.25: 5 steps calling web_search (4×) and web_scraper (1×), ending with the answer "The latest stable Python 3 release is Python 3.15.2, according to https://www.python.org/downloads/." The success criterion is this answer, not the exit code: the CLI currently exits 0 even when a task fails, a known defect pinned in RTM-0: characterization tests, hermetic test lane, locked CI, and runtime ADR (proposed) #8.
    • uv audit --locked: 158 advisories on the same lock resolution before and after the bump, none for LiteLLM.

Alternatives tried and rejected:

Option Result
Upgrade mcp to 2.3.0 Agent runs work, but all 4 real MCP lifecycle tests fail: mcpadapt 0.1.19 imports streamablehttp_client, which mcp 2.x removed, and no mcpadapt release supports mcp 2.x yet. It also drops the ws extra that mcpadapt requests.
LiteLLM 1.112.2 Works, but leaves the LTS line Plan 005 chose and forks the lock by Python version.
Pass LiteLLM's private _skip_mcp_handler flag Not used: it is a private parameter and could change without notice.

Merge Danger

Door: two-way

Reverting restores LiteLLM 1.108.3, along with the broken tool-calling path.

Blast Radius: Dependencies

  • A patch-level upgrade within the same LiteLLM LTS line; no other resolved package changes.
  • The test run shows 10 pydantic UserWarnings raised while LiteLLM's own type definitions load. They are third-party, not deprecations, and harmless.
  • Live runs also need a valid OPENROUTER_API_KEY. A stale key gives 401 User not found, which is unrelated to this fix.

LiteLLM 1.108.3 imported its proxy MCP gateway on every completion() that passed tools; that module needs mcp>=2.3 (mcp.types.CacheableResult), but the lock keeps mcp 1.23.2 for smolagents/mcpadapt, so every live agent run failed with ImportError. 1.108.25 (same LTS line) only imports the gateway when tools reference it. Only litellm changes in uv.lock; uv audit advisory count unchanged. Adds offline regression tests using LiteLLM mock_response.
@svngoku svngoku added bug Something isn't working urgent Breaks core functionality on master; review first labels Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working urgent Breaks core functionality on master; review first

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant