diff --git a/libs/core/langchain_core/rate_limiters.py b/libs/core/langchain_core/rate_limiters.py index 986d3ff63b7..f347ded77f6 100644 --- a/libs/core/langchain_core/rate_limiters.py +++ b/libs/core/langchain_core/rate_limiters.py @@ -105,9 +105,7 @@ class InMemoryRateLimiter(BaseRateLimiter): from langchain_anthropic import ChatAnthropic - model = ChatAnthropic( - model_name="claude-sonnet-4-5-20250929", rate_limiter=rate_limiter - ) + model = ChatAnthropic(model_name="claude-sonnet-4-5", rate_limiter=rate_limiter) for _ in range(5): tic = time.time() diff --git a/libs/langchain/langchain_classic/chat_models/base.py b/libs/langchain/langchain_classic/chat_models/base.py index 8fac6261676..04cbaa4e771 100644 --- a/libs/langchain/langchain_classic/chat_models/base.py +++ b/libs/langchain/langchain_classic/chat_models/base.py @@ -88,7 +88,7 @@ def init_chat_model( for supported model parameters. Args: - model: The name of the model, e.g. `'o3-mini'`, `'claude-sonnet-4-5-20250929'`. + model: The name of the model, e.g. `'o3-mini'`, `'claude-sonnet-4-5'`. You can also specify model and model provider in a single argument using: @@ -183,9 +183,7 @@ def init_chat_model( from langchain_classic.chat_models import init_chat_model o3_mini = init_chat_model("openai:o3-mini", temperature=0) - claude_sonnet = init_chat_model( - "anthropic:claude-sonnet-4-5-20250929", temperature=0 - ) + claude_sonnet = init_chat_model("anthropic:claude-sonnet-4-5", temperature=0) gemini_2_flash = init_chat_model( "google_vertexai:gemini-2.5-flash", temperature=0 ) @@ -211,7 +209,7 @@ def init_chat_model( configurable_model.invoke( "what's your name", - config={"configurable": {"model": "claude-sonnet-4-5-20250929"}}, + config={"configurable": {"model": "claude-sonnet-4-5"}}, ) ``` @@ -235,7 +233,7 @@ def init_chat_model( "what's your name", config={ "configurable": { - "foo_model": "anthropic:claude-sonnet-4-5-20250929", + "foo_model": "anthropic:claude-sonnet-4-5", "foo_temperature": 0.6, } }, @@ -285,7 +283,7 @@ def init_chat_model( configurable_model_with_tools.invoke( "Which city is hotter today and which is bigger: LA or NY?", - config={"configurable": {"model": "claude-sonnet-4-5-20250929"}}, + config={"configurable": {"model": "claude-sonnet-4-5"}}, ) ``` diff --git a/libs/langchain_v1/langchain/agents/factory.py b/libs/langchain_v1/langchain/agents/factory.py index e3805000924..abe83db46b8 100644 --- a/libs/langchain_v1/langchain/agents/factory.py +++ b/libs/langchain_v1/langchain/agents/factory.py @@ -3,15 +3,7 @@ from __future__ import annotations import itertools -from typing import ( - TYPE_CHECKING, - Annotated, - Any, - cast, - get_args, - get_origin, - get_type_hints, -) +from typing import TYPE_CHECKING, Annotated, Any, cast, get_args, get_origin, get_type_hints from langchain_core.language_models.chat_models import BaseChatModel from langchain_core.messages import AIMessage, AnyMessage, SystemMessage, ToolMessage @@ -601,7 +593,7 @@ def create_agent( # noqa: PLR0915 graph = create_agent( - model="anthropic:claude-sonnet-4-5-20250929", + model="anthropic:claude-sonnet-4-5", tools=[check_weather], system_prompt="You are a helpful assistant", ) diff --git a/libs/langchain_v1/langchain/chat_models/base.py b/libs/langchain_v1/langchain/chat_models/base.py index 54662e3e70b..e546c3ad84c 100644 --- a/libs/langchain_v1/langchain/chat_models/base.py +++ b/libs/langchain_v1/langchain/chat_models/base.py @@ -4,14 +4,7 @@ from __future__ import annotations import warnings from importlib import util -from typing import ( - TYPE_CHECKING, - Any, - Literal, - TypeAlias, - cast, - overload, -) +from typing import TYPE_CHECKING, Any, Literal, TypeAlias, cast, overload from langchain_core.language_models import BaseChatModel, LanguageModelInput from langchain_core.messages import AIMessage, AnyMessage @@ -83,7 +76,7 @@ def init_chat_model( for supported model parameters. Args: - model: The name of the model, e.g. `'o3-mini'`, `'claude-sonnet-4-5-20250929'`. + model: The name of the model, e.g. `'o3-mini'`, `'claude-sonnet-4-5'`. You can also specify model and model provider in a single argument using: @@ -179,7 +172,7 @@ def init_chat_model( from langchain.chat_models import init_chat_model o3_mini = init_chat_model("openai:o3-mini", temperature=0) - claude_sonnet = init_chat_model("anthropic:claude-sonnet-4-5-20250929", temperature=0) + claude_sonnet = init_chat_model("anthropic:claude-sonnet-4-5", temperature=0) gemini_2_flash = init_chat_model("google_vertexai:gemini-2.5-flash", temperature=0) o3_mini.invoke("what's your name") @@ -201,7 +194,7 @@ def init_chat_model( configurable_model.invoke( "what's your name", - config={"configurable": {"model": "claude-sonnet-4-5-20250929"}}, + config={"configurable": {"model": "claude-sonnet-4-5"}}, ) ``` @@ -225,7 +218,7 @@ def init_chat_model( "what's your name", config={ "configurable": { - "foo_model": "anthropic:claude-sonnet-4-5-20250929", + "foo_model": "anthropic:claude-sonnet-4-5", "foo_temperature": 0.6, } }, @@ -271,7 +264,7 @@ def init_chat_model( configurable_model_with_tools.invoke( "Which city is hotter today and which is bigger: LA or NY?", - config={"configurable": {"model": "claude-sonnet-4-5-20250929"}}, + config={"configurable": {"model": "claude-sonnet-4-5"}}, ) ``` @@ -612,10 +605,7 @@ class _ConfigurableModel(Runnable[LanguageModelInput, Any]): @property def InputType(self) -> TypeAlias: """Get the input type for this `Runnable`.""" - from langchain_core.prompt_values import ( - ChatPromptValueConcrete, - StringPromptValue, - ) + from langchain_core.prompt_values import ChatPromptValueConcrete, StringPromptValue # This is a version of LanguageModelInput which replaces the abstract # base class BaseMessage with a union of its subclasses, which makes diff --git a/libs/partners/anthropic/langchain_anthropic/chat_models.py b/libs/partners/anthropic/langchain_anthropic/chat_models.py index eb2b50b4a00..5c025d03518 100644 --- a/libs/partners/anthropic/langchain_anthropic/chat_models.py +++ b/libs/partners/anthropic/langchain_anthropic/chat_models.py @@ -18,10 +18,7 @@ from langchain_core.callbacks import ( ) from langchain_core.exceptions import OutputParserException from langchain_core.language_models import LanguageModelInput -from langchain_core.language_models.chat_models import ( - BaseChatModel, - LangSmithParams, -) +from langchain_core.language_models.chat_models import BaseChatModel, LangSmithParams from langchain_core.messages import ( AIMessage, AIMessageChunk, @@ -1271,7 +1268,7 @@ class ChatAnthropic(BaseChatModel): from langchain_anthropic import ChatAnthropic model = ChatAnthropic( - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", betas=["context-management-2025-06-27"], context_management={"edits": [{"type": "clear_tool_uses_20250919"}]}, ) @@ -1399,7 +1396,7 @@ class ChatAnthropic(BaseChatModel): from langchain_anthropic import ChatAnthropic model = ChatAnthropic( - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", betas=["context-management-2025-06-27"], ) model_with_tools = model.bind_tools([{"type": "memory_20250818", "name": "memory"}]) diff --git a/libs/partners/anthropic/tests/integration_tests/test_chat_models.py b/libs/partners/anthropic/tests/integration_tests/test_chat_models.py index 3de28782924..01a9a9cbbd6 100644 --- a/libs/partners/anthropic/tests/integration_tests/test_chat_models.py +++ b/libs/partners/anthropic/tests/integration_tests/test_chat_models.py @@ -1810,7 +1810,7 @@ def test_search_result_top_level() -> None: def test_memory_tool() -> None: llm = ChatAnthropic( - model="claude-sonnet-4-5-20250929", # type: ignore[call-arg] + model="claude-sonnet-4-5", # type: ignore[call-arg] betas=["context-management-2025-06-27"], ) llm_with_tools = llm.bind_tools([{"type": "memory_20250818", "name": "memory"}]) @@ -1824,7 +1824,7 @@ def test_memory_tool() -> None: def test_context_management() -> None: # TODO: update example to trigger action llm = ChatAnthropic( - model="claude-sonnet-4-5-20250929", # type: ignore[call-arg] + model="claude-sonnet-4-5", # type: ignore[call-arg] betas=["context-management-2025-06-27"], context_management={ "edits": [ diff --git a/libs/partners/anthropic/tests/unit_tests/test_chat_models.py b/libs/partners/anthropic/tests/unit_tests/test_chat_models.py index 7aabfe860b5..577e3573325 100644 --- a/libs/partners/anthropic/tests/unit_tests/test_chat_models.py +++ b/libs/partners/anthropic/tests/unit_tests/test_chat_models.py @@ -1325,7 +1325,7 @@ def test_get_num_tokens_from_messages_passes_kwargs() -> None: assert _client.return_value.messages.count_tokens.call_args.kwargs["foo"] == "bar" llm = ChatAnthropic( - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", betas=["context-management-2025-06-27"], context_management={"edits": [{"type": "clear_tool_uses_20250919"}]}, ) @@ -1488,7 +1488,7 @@ def test_cache_control_kwarg() -> None: def test_context_management_in_payload() -> None: llm = ChatAnthropic( - model="claude-sonnet-4-5-20250929", # type: ignore[call-arg] + model="claude-sonnet-4-5", # type: ignore[call-arg] betas=["context-management-2025-06-27"], context_management={"edits": [{"type": "clear_tool_uses_20250919"}]}, ) @@ -1514,8 +1514,8 @@ def test_anthropic_model_params() -> None: "ls_temperature": None, } - ls_params = llm._get_ls_params(model="claude-opus-4-1-20250805") - assert ls_params.get("ls_model_name") == "claude-opus-4-1-20250805" + ls_params = llm._get_ls_params(model="claude-opus-4-1") + assert ls_params.get("ls_model_name") == "claude-opus-4-1" def test_streaming_cache_token_reporting() -> None: