Skip to content

fix: adapt UiPathChatAnthropic to the langchain-anthropic 1.7.0 raw-response contract - #133

Open
andreibalas-uipath wants to merge 1 commit into
mainfrom
fix/langchain-anthropic-1.7.0-raw-response
Open

fix: adapt UiPathChatAnthropic to the langchain-anthropic 1.7.0 raw-response contract#133
andreibalas-uipath wants to merge 1 commit into
mainfrom
fix/langchain-anthropic-1.7.0-raw-response

Conversation

@andreibalas-uipath

Copy link
Copy Markdown
Contributor

What changed and why

Follow-up to #132, which pinned langchain-anthropic<1.7.0 as an interim mitigation. This PR is the real fix: it adapts UiPathChatAnthropic to the langchain-anthropic 1.7.0 contract and lifts the pin.

  • UiPathChatAnthropic._create/._acreate now route through with_raw_response.create(...) (both the plain and betas branches). langchain-anthropic 1.7.0 changed these private methods to return a raw-response wrapper and calls .parse() on the result in _generate/_agenerate/_stream/_astream; the previous override bodies returned parsed objects, so every operation failed with 'Message'/'Stream'/'AsyncStream' object has no attribute 'parse'.
  • langchain-anthropic bound on the anthropic and bedrock extras moves from >=1.4.1,<1.7.0 (the fix: bound langchain-anthropic<1.7.0 in uipath-langchain-client #132 pin) to >=1.7.0,<2.0.0.
  • UiPathChatLiteLLM no longer lets ChatLiteLLM's before-validator mark streaming=False as explicitly set: langchain-core >= 1.4 (pulled in by the lock refresh) treats that as a hard streaming opt-out, silently downgrading .stream()/.astream() to non-streaming invokes.
  • New tests: tests/langchain/clients/anthropic/test_raw_response_contract.py (mocked-transport coverage of invoke/stream/tool-calling/structured-output, sync+async, the betas routing branch, and gateway-metadata extraction off the raw wrapper) and tests/langchain/clients/litellm/test_streaming_dispatch.py.

Affected packages

  • uipath-langchain-client only (1.18.3 → 1.18.4). Core untouched.

Verification

  • ruff check, ruff format --check, pyright clean; full suite green (2110+ passed, cassette replay).
  • With main's code + langchain-anthropic 1.7.0, the Anthropic suite fails 121 tests with exactly the errors from the uipath-langchain-python chat-models CI failure ('Message' object has no attribute 'parse', etc.); with this branch it passes 133/133, including the VCR integration tests replaying recorded gateway traffic for the same model/config the failing CI testcase uses (anthropic.claude-haiku-4-5-20251001-v1:0, vendor_type="awsbedrock").

🤖 Generated with Claude Code

…nse contract

- _create/_acreate now return raw-response wrappers (with_raw_response) since
  langchain-anthropic 1.7.0 calls .parse() on the result; previously every
  invoke/stream/tool-calling/structured-output call failed with
  "'Message' object has no attribute 'parse'"
- raise langchain-anthropic floor to >=1.7.0,<2.0.0 (anthropic extra, and
  explicitly on the bedrock extra which pulls it transitively)
- fix UiPathChatLiteLLM stream()/astream() silently degrading to non-streaming
  on langchain-core >= 1.4 (pulled in by langchain-anthropic 1.7.0), caused by
  ChatLiteLLM's validator marking streaming=False as explicitly set
- regenerate uv.lock (langchain-anthropic 1.7.0, anthropic 0.125.0 — still <1.0.0)
- bump uipath-langchain-client to 1.18.2 with changelog entry

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant