The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
release[anthropic]: 0.3.15 (#31479)
Bagatur310e64384296
diff --git a/libs/partners/anthropic/pyproject.toml b/libs/partners/anthropic/pyproject.tomlindex ae3a0d3fe9..be236e4b89 100644--- a/libs/partners/anthropic/pyproject.toml+++ b/libs/partners/anthropic/pyproject.toml@@ -12,7 +12,7 @@ dependencies = ["pydantic<3.0.0,>=2.7.4",]name = "langchain-anthropic"-version = "0.3.14"+version = "0.3.15"description = "An integration package connecting AnthropicMessages and LangChain"readme = "README.md"diff --git a/libs/partners/anthropic/tests/integration_tests/test_chat_models.py b/libs/partners/anthropic/tests/integration_tests/test_chat_models.pyindex de3e453af0..46e95e6ea3 100644--- a/libs/partners/anthropic/tests/integration_tests/test_chat_models.py+++ b/libs/partners/anthropic/tests/integration_tests/test_chat_models.py@@ -3,7 +3,7 @@import jsonimport osfrom base64 import b64encode-from typing import Optional+from typing import Optional, castimport httpximport pytest@@ -42,7 +42,10 @@ def test_stream() -> None:chunks_with_model_name = 0for token in llm.stream("I'm Pickle Rick"):assert isinstance(token.content, str)- full = token if full is None else full + token+ if full is None:+ full = cast(BaseMessageChunk, token)+ else:+ full = full + tokenassert isinstance(token, AIMessageChunk)if token.usage_metadata is not None:if token.usage_metadata.get("input_tokens"):@@ -81,7 +84,10 @@ async def test_astream() -> None:chunks_with_output_token_counts = 0async for token in llm.astream("I'm Pickle Rick"):assert isinstance(token.content, str)- full = token if full is None else full + token+ if full is None:+ full = cast(BaseMessageChunk, token)+ else:+ full = full + tokenassert isinstance(token, AIMessageChunk)if token.usage_metadata is not None:if token.usage_metadata.get("input_tokens"):@@ -697,7 +703,10 @@ def test_citations() -> None:# Test streamingfull: Optional[BaseMessageChunk] = Nonefor chunk in llm.stream(messages):- full = chunk if full is None else full + chunk+ if full is None:+ full = cast(BaseMessageChunk, chunk)+ else:+ full = full + chunkassert isinstance(full, AIMessageChunk)assert isinstance(full.content, list)assert any("citations" in block for block in full.content)@@ -722,7 +731,10 @@ def test_thinking() -> None:# Test streamingfull: Optional[BaseMessageChunk] = Nonefor chunk in llm.stream("Hello"):- full = chunk if full is None else full + chunk+ if full is None:+ full = cast(BaseMessageChunk, chunk)+ else:+ full = full + chunkassert isinstance(full, AIMessageChunk)assert isinstance(full.content, list)assert any("thinking" in block for block in full.content)@@ -756,7 +768,10 @@ def test_redacted_thinking() -> None:# Test streamingfull: Optional[BaseMessageChunk] = Nonefor chunk in llm.stream(query):- full = chunk if full is None else full + chunk+ if full is None:+ full = cast(BaseMessageChunk, chunk)+ else:+ full = full + chunkassert isinstance(full, AIMessageChunk)assert isinstance(full.content, list)stream_has_reasoning = Falsediff --git a/libs/partners/anthropic/tests/integration_tests/test_standard.py b/libs/partners/anthropic/tests/integration_tests/test_standard.pyindex f8c6823bb2..6f4e3f4f98 100644--- a/libs/partners/anthropic/tests/integration_tests/test_standard.py+++ b/libs/partners/anthropic/tests/integration_tests/test_standard.py@@ -4,7 +4,7 @@ from pathlib import Pathfrom typing import Literal, castfrom langchain_core.language_models import BaseChatModel-from langchain_core.messages import AIMessage+from langchain_core.messages import AIMessage, BaseMessageChunkfrom langchain_tests.integration_tests import ChatModelIntegrationTestsfrom langchain_anthropic import ChatAnthropic@@ -146,7 +146,10 @@ def _invoke(llm: ChatAnthropic, input_: list, stream: bool) -> AIMessage:if stream:full = Nonefor chunk in llm.stream(input_):- full = full + chunk if full else chunk # type: ignore[operator]+ if full is None:+ full = cast(BaseMessageChunk, chunk)+ else:+ full = full + chunkreturn cast(AIMessage, full)else:return cast(AIMessage, llm.invoke(input_))diff --git a/libs/partners/anthropic/uv.lock b/libs/partners/anthropic/uv.lockindex 60d0f20fd7..6fb205cdd2 100644--- a/libs/partners/anthropic/uv.lock+++ b/libs/partners/anthropic/uv.lock@@ -1,4 +1,5 @@version = 1+revision = 1requires-python = ">=3.9"resolution-markers = ["python_full_version >= '3.13' and platform_python_implementation == 'PyPy'",@@ -423,7 +424,7 @@ wheels = [[[package]]name = "langchain-anthropic"-version = "0.3.14"+version = "0.3.15"source = { editable = "." }dependencies = [{ name = "anthropic" },