Repository navigation
fix(templates): keep litellm below 1.106.0 in LiteLLM Strands projects - #2980
Conversation
litellm 1.106.0 and later import CacheableResult from mcp.types, which exists only in mcp 2.x. bedrock-agentcore[strands-agents] requires mcp<2.0.0, so every model call that passes tools failed with an ImportError wrapped as APIConnectionError.
Package TarballHow to installgh release download pr-2980-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-1.4.0.tgz |
|
Claude Security Review: no high-confidence findings. (run) |
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Looks good
I verified the premise of the fix independently against PyPI and the wheels:
bedrock-agentcore[strands-agents] 1.29.0requiresmcp<2.0.0,>=1.23.0.strands-agentslatest (1.68.0, matched by>= 1.62.0, < 2.0.0/>= 1.63.0, < 2.0.0) declareslitellm<1.107.0,>=1.75.9for itslitellmextra, so1.106.xis reachable today — the cap is genuinely needed.litellm 1.106.0'slitellm/experimental_mcp_client/client.pyimportsCacheableResult(andhttpx2) from themcp2.x API;1.105.7does not. The< 1.106.0boundary is the right one.- The claim about
a2a-python-strandschecks out:strands-agents 1.57.2pinslitellm<=1.96.0,>=1.75.9for thelitellmextra, so~= 1.57.2already excludes the broken range. Leaving that template alone is correct.
Rendering also looks right: renderer.ts uses default Handlebars compile options (no ignoreStandalone), so the standalone {{#if}}/{{/if}} lines are stripped and no blank line lands inside the dependencies array — which the new test's adjacency assertion happens to confirm. The box variant picks the cap up for free, since runtime.ts renders agent-python-strands's pyproject.toml with the same context and only swaps the Dockerfile/.gitignore. No snapshots or other golden files reference these dependency lists.
Nothing blocking. Three small, optional notes:
src/assets/templates/export-harness-python/pyproject.tomlis the one changed template with no coverage — the newruntime.test.tscase only exercisesagent-python-strandsandagui-python-strands, andpythonSecurity.test.tsrenders the harness template withmodelProvider: "Bedrock"only. There is already a natural home for a one-line assertion:src/core/project/manager.export.test.ts:798("renders LiteLLM settings with the LiteLLM extra") reads the exportedpyproject.tomland assertsstrands-agents[litellm,web-fetch]; addingexpect(...).toContain('"litellm < 1.106.0"')there would cover the export path end to end.- The new assertion
pyproject.includes(' "litellm < 1.106.0",\n "strands-agents[')couples to indentation and line ordering while verifying little beyond presence.pythonSecurity.test.tsalready shows the sturdier form:Bun.TOML.parse(pyproject)plusexpect.arrayContaining/not.toContainonproject.dependencies. - The cap has no rationale recorded where a future maintainer will look. A
{{!-- --}}comment above the block (the templates already use that style, e.g.model/load.py:1) saying the cap exists becauselitellm >= 1.106needsmcp2.x whilebedrock-agentcore[strands-agents]pinsmcp < 2.0.0, and can be lifted when that pin moves, would keep the PR description's reasoning with the code — it also ships into user projects, where an unexplained upper bound is otherwise a mystery.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v1.x #2980 +/- ##
=======================================
Coverage 97.08% 97.08%
=======================================
Files 793 793
Lines 72910 72910
=======================================
Hits 70783 70783
Misses 2127 2127 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Thanks @tejaskash for narrowing this to LiteLLM projects. I reproduced the import failure on a clean Python 3.14 install with LiteLLM 1.106.12 and MCP 1.30.0. With the cap, the same project resolved LiteLLM 1.105.7 and both the MCP handler and the Strands LiteLLM model imported successfully.
Non-blocking test suggestion: could we assert that the rendered dependency list contains the cap, rather than requiring it to appear immediately before the Strands entry? That would tolerate harmless reordering. It would also be useful to cover the rendered Harness export manifest, since it is the third template changed here.
What
Adds
"litellm < 1.106.0"to the generatedpyproject.tomlwhen the model provider is LiteLLM, in theagent-python-strands,agui-python-strandsandexport-harness-pythontemplates.Why
litellm1.106.0 and later importCacheableResultfrommcp.types, which exists only inmcp2.x.bedrock-agentcore[strands-agents]requiresmcp<2.0.0, so a new LiteLLM project installslitellm1.106.12 withmcp1.30.0. Every model call that passes tools then fails with:a2a-python-strandsis not changed. Itsstrands-agents ~= 1.57.2pin already limitslitellmto 1.96.0 or lower.The cap can be removed once
bedrock-agentcore[strands-agents]allowsmcp2.x.How tested
runtime.test.tschecks that the cap is rendered for LiteLLM and not for OpenAI.uvinstallslitellm1.106.12 andfrom litellm.responses.mcp.litellm_proxy_mcp_handler import LiteLLM_Proxy_MCP_Handlerfails with the error above. With the cap,uvinstallslitellm1.105.7 and the import passes, as doesfrom strands.models.litellm import LiteLLMModel.bun run typecheck,bun run lint:checkand the template, export and manager export test files pass.