The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
feat(anthropic): add Claude Opus 5 support (#39054)
Hunter Lovell76b4b2472a64
diff --git a/libs/partners/anthropic/langchain_anthropic/chat_models.py b/libs/partners/anthropic/langchain_anthropic/chat_models.pyindex 103e655d3c..2668e0e27a 100644--- a/libs/partners/anthropic/langchain_anthropic/chat_models.py+++ b/libs/partners/anthropic/langchain_anthropic/chat_models.py@@ -1019,17 +1019,19 @@ class ChatAnthropic(BaseChatModel):Examples:- `#!python {"type": "enabled", "budget_tokens": 10_000}` (pre-4.7 models)- - `#!python {"type": "adaptive"}` (Opus 4.6+, Sonnet 5)- - `#!python {"type": "adaptive", "display": "summarized"}` (Opus 4.7+, Sonnet 5)- - `#!python {"type": "disabled"}` (Sonnet 5, where adaptive thinking is- on by default)+ - `#!python {"type": "adaptive"}` (Opus 4.6+, Opus 5, Sonnet 5)+ - `#!python {"type": "adaptive", "display": "summarized"}` (Opus 4.7+,+ Opus 5, Sonnet 5)+ - `#!python {"type": "disabled"}` (Opus 5 and Sonnet 5, where adaptive+ thinking is on by default)- !!! note "Claude Opus 4.7+ and Sonnet 5"+ !!! note "Claude Opus 4.7+, Opus 5, and Sonnet 5"`budget_tokens` is removed on these models — use `{"type": "adaptive"}`with `output_config.effort` to control reasoning effort. The default`display` is `"omitted"`; set it to `"summarized"` to receive- summarized reasoning in the response.+ summarized reasoning in the response. On Opus 5, disabled thinking is+ supported only at `"high"` effort or below."""output_config: dict[str, Any] | None = None@@ -1288,6 +1290,51 @@ class ChatAnthropic(BaseChatModel):}return anthropic.AsyncClient(**params)+ def _assert_valid_model_configuration(self, kwargs: Mapping[str, Any]) -> None:+ """Validate resolved request configuration against model-specific invariants."""+ request_config = {**self.model_kwargs, **kwargs}+ thinking = request_config.get("thinking")+ if self.thinking is not None:+ thinking = self.thinking++ output_config = dict(self.output_config or {})+ if self.reasoning_effort:+ output_config["effort"] = self.reasoning_effort+ request_output_config = request_config.get("output_config")+ if isinstance(request_output_config, dict):+ output_config.update(request_output_config)+ effort = request_config.get("effort")+ if effort is None:+ effort = request_config.get("reasoning_effort")+ if effort:+ output_config["effort"] = effort++ if (+ self.model.startswith("claude-opus-5")+ and isinstance(thinking, Mapping)+ and thinking.get("type") == "enabled"+ ):+ msg = (+ '`thinking={"type": "enabled", "budget_tokens": ...}` is not '+ f"supported for {self.model}; use adaptive thinking and "+ "`output_config.effort` instead."+ )+ raise ValueError(msg)++ if (+ self.model.startswith("claude-opus-5")+ and isinstance(thinking, Mapping)+ and thinking.get("type") == "disabled"+ and output_config.get("effort") in {"xhigh", "max"}+ ):+ msg = (+ '`thinking={"type": "disabled"}` is not supported for '+ f"{self.model} with "+ f"`output_config.effort={output_config['effort']!r}`; use adaptive "+ "thinking, omit `thinking`, or set effort to `high` or below."+ )+ raise ValueError(msg)+def _get_request_payload(self,input_: LanguageModelInput,@@ -1296,6 +1343,7 @@ class ChatAnthropic(BaseChatModel):**kwargs: Any,) -> dict:"""Get the request payload for the Anthropic API."""+ self._assert_valid_model_configuration(kwargs)messages = self._convert_input(input_).to_messages()for idx, message in enumerate(messages):diff --git a/libs/partners/anthropic/langchain_anthropic/data/_profiles.py b/libs/partners/anthropic/langchain_anthropic/data/_profiles.pyindex 8cd447c64b..92da1d7f6c 100644--- a/libs/partners/anthropic/langchain_anthropic/data/_profiles.py+++ b/libs/partners/anthropic/langchain_anthropic/data/_profiles.py@@ -313,6 +313,40 @@ _PROFILES: dict[str, dict[str, Any]] = {],"reasoning_effort_default": "high",},+ "claude-opus-5": {+ "name": "Claude Opus 5",+ "release_date": "2026-07-24",+ "last_updated": "2026-07-24",+ "open_weights": False,+ "max_input_tokens": 1000000,+ "max_output_tokens": 128000,+ "text_inputs": True,+ "image_inputs": True,+ "audio_inputs": False,+ "pdf_inputs": True,+ "video_inputs": False,+ "text_outputs": True,+ "image_outputs": False,+ "audio_outputs": False,+ "video_outputs": False,+ "reasoning_output": True,+ "tool_calling": True,+ "structured_output": True,+ "attachment": True,+ "temperature": False,+ "image_url_inputs": True,+ "pdf_tool_message": True,+ "image_tool_message": True,+ "tool_call_streaming": True,+ "reasoning_effort_levels": [+ "low",+ "medium",+ "high",+ "xhigh",+ "max",+ ],+ "reasoning_effort_default": "high",+ },"claude-sonnet-4-5": {"name": "Claude Sonnet 4.5 (latest)","release_date": "2025-09-29",diff --git a/libs/partners/anthropic/langchain_anthropic/data/profile_augmentations.toml b/libs/partners/anthropic/langchain_anthropic/data/profile_augmentations.tomlindex 05a378b169..c97a7f08a3 100644--- a/libs/partners/anthropic/langchain_anthropic/data/profile_augmentations.toml+++ b/libs/partners/anthropic/langchain_anthropic/data/profile_augmentations.toml@@ -46,6 +46,11 @@ structured_output = truereasoning_effort_levels = ["low", "medium", "high", "xhigh", "max"]reasoning_effort_default = "high"+[overrides."claude-opus-5"]+structured_output = true+reasoning_effort_levels = ["low", "medium", "high", "xhigh", "max"]+reasoning_effort_default = "high"+[overrides."claude-sonnet-5"]reasoning_effort_levels = ["low", "medium", "high", "xhigh", "max"]reasoning_effort_default = "high"diff --git a/libs/partners/anthropic/pyproject.toml b/libs/partners/anthropic/pyproject.tomlindex 237d43a2ff..e5ce375803 100644--- a/libs/partners/anthropic/pyproject.toml+++ b/libs/partners/anthropic/pyproject.toml@@ -23,7 +23,7 @@ classifiers = [version = "1.5.1"requires-python = ">=3.10.0,<4.0.0"dependencies = [- "anthropic>=0.96.0,<1.0.0",+ "anthropic>=0.120.0,<1.0.0","langchain-core>=1.5.1,<2.0.0","pydantic>=2.7.4,<3.0.0",]diff --git a/libs/partners/anthropic/tests/integration_tests/test_chat_models.py b/libs/partners/anthropic/tests/integration_tests/test_chat_models.pyindex b186cc466d..ffac6bfbeb 100644--- a/libs/partners/anthropic/tests/integration_tests/test_chat_models.py+++ b/libs/partners/anthropic/tests/integration_tests/test_chat_models.py@@ -1353,13 +1353,13 @@ def test_reasoning_effort_call_time_kwarg() -> None:def test_reasoning_effort_defaults_adaptive_thinking() -> None:"""`reasoning_effort` defaults `thinking` to adaptive on models that support it.- Regression test for a model (Opus 4.7+, Sonnet 5) actually accepting the+ Regression test for a model (Opus 4.7+, Opus 5, Sonnet 5) actually accepting theresulting `{"type": "adaptive", "display": "summarized"}` thinking config,not just that the payload is well-formed locally."""llm = ChatAnthropic(- model="claude-opus-4-7",- reasoning_effort="xhigh",+ model="claude-opus-5",+ reasoning_effort="high",max_tokens=2_000,)diff --git a/libs/partners/anthropic/tests/unit_tests/test_chat_models.py b/libs/partners/anthropic/tests/unit_tests/test_chat_models.pyindex c2de631c28..56c4986762 100644--- a/libs/partners/anthropic/tests/unit_tests/test_chat_models.py+++ b/libs/partners/anthropic/tests/unit_tests/test_chat_models.py@@ -2826,10 +2826,18 @@ def test_auto_append_betas_for_mcp_servers() -> None:}-def test_claude_opus_4_8_profile_supports_structured_output() -> None:- model = ChatAnthropic(model="claude-opus-4-8")+def test_claude_opus_5_profile_supports_structured_output() -> None:+ model = ChatAnthropic(model="claude-opus-5")assert model.profileassert model.profile["structured_output"] is True+ assert model.profile["max_input_tokens"] == 1_000_000+ assert model.profile["reasoning_effort_levels"] == [+ "low",+ "medium",+ "high",+ "xhigh",+ "max",+ ]def test_profile() -> None:@@ -3040,12 +3048,12 @@ def test_reasoning_effort_defaults_adaptive_thinking() -> None:reasoning mode to apply it to. Only models whose profile advertises`xhigh` (Opus 4.7+, Sonnet 5) accept this `thinking` shape."""- model = ChatAnthropic(model="claude-opus-4-7", reasoning_effort="high")+ model = ChatAnthropic(model="claude-opus-5", reasoning_effort="low")payload = model._get_request_payload("Test query")assert payload["thinking"] == {"type": "adaptive", "display": "summarized"}- assert payload["output_config"]["effort"] == "high"+ assert payload["output_config"]["effort"] == "low"def test_reasoning_effort_as_call_time_kwarg_defaults_adaptive_thinking() -> None:@@ -3099,6 +3107,63 @@ def test_reasoning_effort_preserves_explicit_call_time_thinking() -> None:assert payload["thinking"] == {"type": "disabled"}[email protected]("effort", ["xhigh", "max"])+def test_opus_5_rejects_disabled_thinking_at_high_effort(effort: str) -> None:+ """Opus 5 permits disabled thinking only through `high` effort."""+ model = ChatAnthropic(+ model="claude-opus-5",+ thinking={"type": "disabled"},+ output_config={"effort": effort},+ )++ with pytest.raises(+ ValueError,+ match=r"not supported for claude-opus-5.*set effort to `high` or below",+ ):+ model._get_request_payload("Test query")+++def test_opus_5_allows_disabled_thinking_at_high_effort() -> None:+ """Opus 5 accepts disabled thinking at `high` effort."""+ model = ChatAnthropic(+ model="claude-opus-5",+ thinking={"type": "disabled"},+ output_config={"effort": "max"},+ )++ payload = model._get_request_payload("Test query", output_config={"effort": "high"})++ assert payload["thinking"] == {"type": "disabled"}+ assert payload["output_config"]["effort"] == "high"++[email protected]("effort", ["xhigh", "max"])+def test_opus_5_rejects_call_time_disabled_thinking_at_high_effort(+ effort: str,+) -> None:+ """Preflight validates call-time effort overrides before message conversion."""+ model = ChatAnthropic(+ model="claude-opus-5",+ thinking={"type": "disabled"},+ )++ with pytest.raises(ValueError, match=r"not supported for claude-opus-5"):+ model._get_request_payload("Test query", output_config={"effort": effort})++[email protected]("effort", ["low", "medium", "high", "xhigh", "max"])+def test_opus_5_rejects_manual_thinking_at_all_effort_levels(effort: str) -> None:+ """Opus 5 does not support manual extended thinking."""+ model = ChatAnthropic(+ model="claude-opus-5",+ thinking={"type": "enabled", "budget_tokens": 1_024},+ output_config={"effort": effort},+ )++ with pytest.raises(ValueError, match=r"use adaptive thinking"):+ model._get_request_payload("Test query")++def test_effort_also_defaults_adaptive_thinking() -> None:"""Test that `effort` composes with the adaptive-thinking default too.diff --git a/libs/partners/anthropic/uv.lock b/libs/partners/anthropic/uv.lockindex 565d6223c5..d02fdb3766 100644--- a/libs/partners/anthropic/uv.lock+++ b/libs/partners/anthropic/uv.lock@@ -29,7 +29,7 @@ wheels = [[[package]]name = "anthropic"-version = "0.96.0"+version = "0.120.0"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "anyio" },@@ -41,9 +41,9 @@ dependencies = [{ name = "sniffio" },{ name = "typing-extensions" },]-sdist = { url = "https://files.pythonhosted.org/packages/b9/7e/672f533dee813028d2c699bfd2a7f52c9118d7353680d9aa44b9e23f717f/anthropic-0.96.0.tar.gz", hash = "sha256:9de947b737f39452f68aa520f1c2239d44119c9b73b0fb6d4e6ca80f00279ee6", size = 658210, upload-time = "2026-04-16T14:28:02.846Z" }+sdist = { url = "https://files.pythonhosted.org/packages/92/5c/3331da4fc009d448008a50c78d86cc929e8c937cd1442245ce3f80561c4e/anthropic-0.120.0.tar.gz", hash = "sha256:6ba6007dc9b00365b20f6101a6618f5196ac1ceef81512e4b5cc0e7436d4975d", size = 1008042, upload-time = "2026-07-24T16:32:52.384Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/48/5a/72f33204064b6e87601a71a6baf8d855769f8a0c1eaae8d06a1094872371/anthropic-0.96.0-py3-none-any.whl", hash = "sha256:9a6e335a354602a521cd9e777e92bfd46ba6e115bf9bbfe6135311e8fb2015b2", size = 635930, upload-time = "2026-04-16T14:28:01.436Z" },+ { url = "https://files.pythonhosted.org/packages/1b/8a/8522bdf809e1f95f0d9c936540987a3f6afba01d2921a2bf488dedf836a8/anthropic-0.120.0-py3-none-any.whl", hash = "sha256:591bd531563ec7b63a1e138f5c11f14cb94edda99623b349c2ce2ece8e08b8a5", size = 1022602, upload-time = "2026-07-24T16:32:50.506Z" },][[package]]@@ -657,7 +657,7 @@ typing = [[package.metadata]requires-dist = [- { name = "anthropic", specifier = ">=0.96.0,<1.0.0" },+ { name = "anthropic", specifier = ">=0.120.0,<1.0.0" },{ name = "langchain-core", editable = "../../core" },{ name = "pydantic", specifier = ">=2.7.4,<3.0.0" },]@@ -690,7 +690,7 @@ typing = [[[package]]name = "langchain-core"-version = "1.5.0"+version = "1.5.1"source = { editable = "../../core" }dependencies = [{ name = "jsonpatch" },