Skip to content

fix(llamaindex): cap anthropic below 2.0 in the bedrock extra - #384

Merged
daniel-joica merged 2 commits into
mainfrom
fix/llamaindex-cap-anthropic
Nov 10, 2026
Merged

daniel-joica merged 2 commits into
mainfrom
fix/llamaindex-cap-anthropic

Conversation

@daniel-joica

@daniel-joica daniel-joica commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

UiPathChatBedrock (the legacy Bedrock class, not UiPathChatBedrockConverse) fails on every method with TypeError: Cannot instantiate typing.Union for any fresh install of uipath-llamaindex[bedrock]. This PR caps anthropic below 2.0 in the bedrock extra.

It affects users as well as CI. uipath-llamaindex/chat-models is red on every LlamaIndex PR, e.g. #383.

Root cause

A breaking change in anthropic 2.0 (released 2026-10-21), which nothing in our dependency chain caps:

uipath-llamaindex[bedrock]
  └ llama-index-llms-bedrock 0.6.0                 (latest)
      └ llama-index-llms-anthropic >=0.8.0, <0.9   → 0.8.6 (Sep 2025)
          └ anthropic >=0.62.0                     → no upper bound → 2.7.0
  • llama-index-llms-anthropic 0.8.6 builds messages with anthropic.types.MessageParam(role=..., content=...) in llama_index/llms/anthropic/utils.py (messages_to_anthropic_messages).
  • In anthropic 2.x, MessageParam is Union[UserMessageParam, AssistantMessageParam, SystemMessageParam], and a Union can't be called. The error is raised while the request is being built, before anything is sent.
  • llama-index-llms-bedrock caps llama-index-llms-anthropic at <0.9, so the newer adapters (now at 0.12.3) can't be resolved.
  • uipath-llamaindex didn't constrain anthropic, so it took the newest major version.

Why it showed up now

  • Last green chat-models run: 2026-10-21 12:58 UTC, with anthropic 1.17.0.
  • anthropic 2.0.0: released the same day at 15:51 UTC.
  • Package unit tests: kept passing because uv.lock pins anthropic 0.84.0. The chat-models testcase resolves without a lock, so it gets the newest version.

Evidence

  • CI on feat(llamaindex): let the LLM Gateway record model spans #383: in chat-models on alpha, cloud and staging, UiPathChatBedrock fails all 9 methods in both testcase runs. UiPathOpenAI, UiPathChatBedrockConverse and UiPathVertex pass all 20 checks each.
  • main (a2c92fb), testcase env resolved as CI does, against a non-routable URL:
    • anthropic 2.7.0 → Cannot instantiate typing.Union
    • anthropic 1.17.0 → the request is sent (it fails only because the URL is fake)
  • This branch, fresh resolution: anthropic 1.17.0, llama-index-llms-bedrock 0.6.0, llama-index-llms-anthropic 0.8.6, llama-index-llms-bedrock-converse 0.15.5. UiPathChatBedrock sends the request.

Change

  • bedrock extra: anthropic>=0.62.0, <2.0.0. The floor matches llama-index-llms-anthropic's own requirement.
  • Version: 0.6.2 → 0.6.3, so the fix gets published.
  • uv.lock: only the new requirement and the version. The locked anthropic stays at 0.84.0, and the lock format stays at revision = 3.

The cap can be removed once llama-index-llms-bedrock allows llama-index-llms-anthropic>=0.9.

Checks

mypy, ruff check, ruff format --check and the package tests (166) pass locally.

🤖 Generated with Claude Code

UiPathChatBedrock fails on every call with "Cannot instantiate
typing.Union" on fresh installs of uipath-llamaindex[bedrock].

llama-index-llms-bedrock 0.6.0 pins llama-index-llms-anthropic<0.9, whose
0.8.x calls anthropic.types.MessageParam(...). In anthropic 2.x (released
2026-10-21) MessageParam is a Union and can't be called. Nothing in the chain
caps anthropic (llama-index-llms-anthropic only asks for >=0.62.0), so new
resolutions pick up 2.x.

Cap it at <2.0.0, with the adapter's own floor, until llama-index-llms-bedrock
allows a newer llama-index-llms-anthropic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 10, 2026 13:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the Bedrock dependency compatibility update.

No open issues 🎉

What changed in this PR

Fixes fresh installations of uipath-llamaindex[bedrock] by excluding Anthropic 2.x, which is incompatible with the legacy UiPathChatBedrock adapter.

Changes:

  • Adds anthropic>=0.62.0, <2.0.0 to the Bedrock extra and documents the compatibility constraint.
  • Bumps the package version to 0.6.3.
  • Updates lockfile metadata while retaining the locked Anthropic version and lock format.
File Description
packages/​uipath-llamaindex/​uv.lock Synchronizes the package version and Bedrock dependency metadata.
packages/​uipath-llamaindex/​pyproject.toml Adds the Anthropic constraint and explanation; bumps the release version.

Review effort: Balanced

The rationale lives in the PR description and the previous commit message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@daniel-joica
daniel-joica merged commit 80e9df5 into main Nov 10, 2026
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants