diff --git a/docs/PLANS.md b/docs/PLANS.md index aad9208..45e9a1d 100644 --- a/docs/PLANS.md +++ b/docs/PLANS.md @@ -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 diff --git a/tests/test_litellm_tool_calls.py b/tests/test_litellm_tool_calls.py new file mode 100644 index 0000000..4503da6 --- /dev/null +++ b/tests/test_litellm_tool_calls.py @@ -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" diff --git a/uv.lock b/uv.lock index 92611ba..68b5500 100644 --- a/uv.lock +++ b/uv.lock @@ -1378,7 +1378,7 @@ wheels = [ [[package]] name = "litellm" -version = "1.108.3" +version = "1.108.25" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "aiohttp" }, @@ -1403,15 +1403,15 @@ dependencies = [ { name = "tokenizers" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/f3/e5/12c5184d984554d968cd8f8963b604e4759ffcdb8d5a63d3996529746bd1/litellm-1.108.3.tar.gz", hash = "sha256:b6ce7a78efbaff7214e731ba0769b156e05b150d05184def61913ee9ff0befb3", size = 21457171, upload-time = "2026-11-07T22:26:06.992Z" } +sdist = { url = "https://files.pythonhosted.org/packages/6e/90/203a98582b9d801756ae489e7f4d0433285757e3132a49c52f4ad6deca34/litellm-1.108.25.tar.gz", hash = "sha256:056593178e81e4970e283195c75d6a99ee75c33e18f1266244416f45710d0d3d", size = 21820126, upload-time = "2026-12-04T22:07:28.542Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/2a/8e/45520278f600465f8e3d155e604ba17b4a10688e7be45260f8c0f673591b/litellm-1.108.3-cp310-abi3-macosx_10_12_x86_64.whl", hash = "sha256:8267641fce3803bb7a56bd6ff046d4919bbd079c96c9d9c1c4c43fdf96d5244c", size = 35863180, upload-time = "2026-11-07T22:25:38.857Z" }, - { url = "https://files.pythonhosted.org/packages/52/15/b45ffb4cd6f82e26b37eba73a3c9191677186f8de61fe145a886eaa30590/litellm-1.108.3-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:9955cc7a29b3060bb791a90cefb6d10df2f0cf63ea720c9d3a26bc8d253eae43", size = 34971257, upload-time = "2026-11-07T22:25:43.822Z" }, - { url = "https://files.pythonhosted.org/packages/53/90/a4bc7b59649537dec77a659affab8f8b8c5eec5af6402008a15ecc294112/litellm-1.108.3-cp310-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:ffd746c20138a078c451a851a68c85da43d67e114001e4a4cd4082953de5494d", size = 35474892, upload-time = "2026-11-07T22:25:47.069Z" }, - { url = "https://files.pythonhosted.org/packages/77/48/deba4c906336f0c9569e00800f9c5a82ac14326d79254bdc0e58d743d6e2/litellm-1.108.3-cp310-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:4ac55c4a80be5b131659b1f42487de96fed69c6717745953c74fede1d6a5113c", size = 36341841, upload-time = "2026-11-07T22:25:50.484Z" }, - { url = "https://files.pythonhosted.org/packages/44/ce/dab82ec6e7706339642bea58ff01811e48507c6cef1bdead42cd390d480a/litellm-1.108.3-cp310-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:46a78bfe948a25cd678acc8a1ed442775688e2b60bda6ac2166ae5b48b747d08", size = 35603914, upload-time = "2026-11-07T22:25:57.199Z" }, - { url = "https://files.pythonhosted.org/packages/2b/6a/129d6b210e25ce6fa3a1eb119ee78968547861d9887575e3b159a2ff67a3/litellm-1.108.3-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:e74f7a0df27ac03eb2280e23c5a72a52a0d64260a96b0da3f95be60ae872469b", size = 36406511, upload-time = "2026-11-07T22:26:00.27Z" }, - { url = "https://files.pythonhosted.org/packages/a4/57/852070eb90b57d21f7707d57384e9bc8da26d8478a081d0088164343561e/litellm-1.108.3-cp310-abi3-win_amd64.whl", hash = "sha256:efdd0d6c57c9814673ee9c491c428945fd58ffb84842557759d2209403dc033e", size = 37013327, upload-time = "2026-11-07T22:26:03.825Z" }, + { url = "https://files.pythonhosted.org/packages/52/b7/625d0cccb4cda9887908f3a0bef159618b8b17dc8bfd117288f48273f00e/litellm-1.108.25-cp310-abi3-macosx_10_12_x86_64.whl", hash = "sha256:2128600cd9d2a94e5f460c9c13ba85f3db5dfc49a6e2ba0bfc27e79a31376d84", size = 36951808, upload-time = "2026-12-04T22:07:05.807Z" }, + { url = "https://files.pythonhosted.org/packages/e7/d6/d0b991a82d91fb4f286abfabea64de358122e983068dbf75564c60788c9c/litellm-1.108.25-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:4d3549096c0aa9fdc153367c2879c29225a1ec53beb90b8a0c8571ed54f19fef", size = 36255820, upload-time = "2026-12-04T22:07:09.276Z" }, + { url = "https://files.pythonhosted.org/packages/b5/3a/29179617e07e29966f980bf4ee97301598e0a14f6f0be995a6a23aaa51b6/litellm-1.108.25-cp310-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:57d1d870a9ca48fdf3968a368190b8d4331e3d3ae1b1fec2f723254ce66f8387", size = 36773188, upload-time = "2026-12-04T22:07:12.459Z" }, + { url = "https://files.pythonhosted.org/packages/68/5e/e1793b9aabba9e73e1f3ce06ba34a425bb14adc97cd12c95cd6d10ff9fa9/litellm-1.108.25-cp310-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:98cdf2c9b947c2e74f26ec9b691f7ffa481f5503a19128104e8f7442c66230d3", size = 37491506, upload-time = "2026-12-04T22:07:15.508Z" }, + { url = "https://files.pythonhosted.org/packages/0d/9f/1af11801f7c9f7d1c712608572c8240eaeb95d7a7f284932d4d698aa92e3/litellm-1.108.25-cp310-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:71351caa09a8173ab6b13718200d281732547a216805b999cddf14be2fb53f8e", size = 36952679, upload-time = "2026-12-04T22:07:19.544Z" }, + { url = "https://files.pythonhosted.org/packages/97/a2/a025be8c2e8a33636c1246912a2bb26673dbc1f877c282b90ffe56512464/litellm-1.108.25-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:303aefd6509de48c272ee36fe3e372c41ae0a1e8ada41f7d398c47f426c179bb", size = 37609771, upload-time = "2026-12-04T22:07:22.552Z" }, + { url = "https://files.pythonhosted.org/packages/3a/c0/0da811fbd50a4b82fe68639d50894b69c079693a9dcfd1b844dce8942c5c/litellm-1.108.25-cp310-abi3-win_amd64.whl", hash = "sha256:d77924c72bd35c413460bdb89b3d0155ee2a5d1c901a03a457fcddb6034d8e5d", size = 38394309, upload-time = "2026-12-04T22:07:25.599Z" }, ] [[package]]