Skip to content

fix(templates): keep litellm below 1.106.0 in LiteLLM Strands projects - #2980

Merged
tejaskash merged 1 commit into
v1.xfrom
fix/litellm-mcp-cap
Dec 1, 2026
Merged

tejaskash merged 1 commit into
v1.xfrom
fix/litellm-mcp-cap

Conversation

@tejaskash

Copy link
Copy Markdown
Contributor

What

Adds "litellm < 1.106.0" to the generated pyproject.toml when the model provider is LiteLLM, in the agent-python-strands, agui-python-strands and export-harness-python templates.

Why

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 a new LiteLLM project installs litellm 1.106.12 with mcp 1.30.0. Every model call that passes tools then fails with:

litellm.APIConnectionError: APIConnectionError: OpenAIException - cannot import name 'CacheableResult' from 'mcp.types'

a2a-python-strands is not changed. Its strands-agents ~= 1.57.2 pin already limits litellm to 1.96.0 or lower.

The cap can be removed once bedrock-agentcore[strands-agents] allows mcp 2.x.

How tested

  • Unit: a new parameterized test in runtime.test.ts checks that the cap is rendered for LiteLLM and not for OpenAI.
  • Real install on Python 3.14 with the template's dependencies. Without the cap, uv installs litellm 1.106.12 and from litellm.responses.mcp.litellm_proxy_mcp_handler import LiteLLM_Proxy_MCP_Handler fails with the error above. With the cap, uv installs litellm 1.105.7 and the import passes, as does from strands.models.litellm import LiteLLMModel.
  • bun run typecheck, bun run lint:check and the template, export and manager export test files pass.

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.
@tejaskash
tejaskash requested a review from a team December 1, 2026 04:39
@github-actions github-actions Bot added the size/s PR size: S label Dec 1, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added agentcore-harness-reviewing AgentCore Harness review in progress claude-security-reviewing Claude Code /security-review in progress labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-1.4.0.tgz

How to install

gh 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

@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Dec 1, 2026

@agentcore-devx-automation agentcore-devx-automation Bot 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.

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.0 requires mcp<2.0.0,>=1.23.0.
  • strands-agents latest (1.68.0, matched by >= 1.62.0, < 2.0.0 / >= 1.63.0, < 2.0.0) declares litellm<1.107.0,>=1.75.9 for its litellm extra, so 1.106.x is reachable today — the cap is genuinely needed.
  • litellm 1.106.0's litellm/experimental_mcp_client/client.py imports CacheableResult (and httpx2) from the mcp 2.x API; 1.105.7 does not. The < 1.106.0 boundary is the right one.
  • The claim about a2a-python-strands checks out: strands-agents 1.57.2 pins litellm<=1.96.0,>=1.75.9 for the litellm extra, so ~= 1.57.2 already 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:

  1. src/assets/templates/export-harness-python/pyproject.toml is the one changed template with no coverage — the new runtime.test.ts case only exercises agent-python-strands and agui-python-strands, and pythonSecurity.test.ts renders the harness template with modelProvider: "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 exported pyproject.toml and asserts strands-agents[litellm,web-fetch]; adding expect(...).toContain('"litellm < 1.106.0"') there would cover the export path end to end.
  2. 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.ts already shows the sturdier form: Bun.TOML.parse(pyproject) plus expect.arrayContaining/not.toContain on project.dependencies.
  3. 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 because litellm >= 1.106 needs mcp 2.x while bedrock-agentcore[strands-agents] pins mcp < 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.

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Dec 1, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.08%. Comparing base (4ac7f3b) to head (77f49e6).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vivdalal vivdalal 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.

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.

@tejaskash
tejaskash merged commit 6aef002 into v1.x Dec 1, 2026
26 of 27 checks passed
@tejaskash
tejaskash deleted the fix/litellm-mcp-cap branch December 1, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants