Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/PLANS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Exec-plans capture non-trivial work before implementation and preserve handoff c
- Plan 004 split 18 multi-model classes into focused modules with original-path compatibility. All 249 tests plus one opt-in skip and an independent AST equivalence check passed.
- Plan 005 upgraded LiteLLM to 1.108.3 with no other direct dependency changes, pinned setup-uv v10.3.3 by full SHA with uv 0.13.7, and documented destination controls. All 250 tests plus one opt-in skip passed; uv audit reports no LiteLLM advisory entry.
- Plans 001-004 preserved dependency versions and resolved dependency identities. Plan 005 changed only LiteLLM and its resolved transitive requirements.
- 2026-12-05 fix: LiteLLM 1.108.3 imported its proxy MCP gateway on every tool-calling `completion()`, which needs `mcp.types.CacheableResult` (mcp>=2.3) while the lock keeps mcp 1.23.2 for smolagents/mcpadapt, so every live agent run failed with `ImportError`. Upgraded to LiteLLM 1.108.25 on the same LTS line (only that package changed; mcp unchanged; `uv audit` advisory count unchanged at 158, none for LiteLLM). Upgrading mcp to 2.3 instead was rejected because mcpadapt 0.1.19 imports `streamablehttp_client`, which mcp 2.x removed. Offline regression tests in `tests/test_litellm_tool_calls.py` use LiteLLM `mock_response`.
- Broader dependency modernization, model-registry consolidation, and execution lifecycle redesign must follow this baseline. They were intentionally outside Plan 001.

## Legacy Plan Location
Expand Down
58 changes: 58 additions & 0 deletions tests/test_litellm_tool_calls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""Regression tests: LiteLLM tool-calling completions must not require MCP 2.x.

LiteLLM 1.108.3 imported its proxy MCP gateway on every ``completion()`` call
that passed ``tools``. That module needs ``mcp.types.CacheableResult`` (mcp>=2.3),
while this project locks mcp 1.x for smolagents/mcpadapt, so every agent run
failed with ``ImportError`` before reaching the provider. LiteLLM 1.108.25 only
imports the gateway when the tools reference it.

``mock_response`` keeps these tests offline: no network call and no API key.
"""

from typing import Any

import litellm
from smolagents import LiteLLMModel, Tool

MODEL_ID = "openrouter/deepseek/deepseek-v4.1-flash-1017"

FUNCTION_TOOL: dict[str, Any] = {
"type": "function",
"function": {
"name": "noop",
"description": "Does nothing.",
"parameters": {"type": "object", "properties": {}},
},
}


class _NoopTool(Tool):
name = "noop"
description = "Does nothing."
inputs: dict[str, Any] = {} # noqa: RUF012
output_type = "string"

def forward(self) -> str:
return "ok"


def test_litellm_completion_with_function_tools_does_not_import_mcp_gateway():
response = litellm.completion(
model=MODEL_ID,
messages=[{"role": "user", "content": "hi"}],
tools=[FUNCTION_TOOL],
mock_response="ok",
)

assert response.choices[0].message.content == "ok"


def test_smolagents_litellm_model_generates_with_tools():
model = LiteLLMModel(model_id=MODEL_ID, api_key="test-key-not-used", mock_response="ok")

message = model.generate(
[{"role": "user", "content": [{"type": "text", "text": "hi"}]}],
tools_to_call_from=[_NoopTool()],
)

assert message.content == "ok"
18 changes: 9 additions & 9 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading