The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
chore: use model IDs, latest anthropic models (#33747)
Mason Daugherty468dad178008
diff --git a/libs/core/langchain_core/callbacks/usage.py b/libs/core/langchain_core/callbacks/usage.pyindex f5b20aef0c..7a77ea970b 100644--- a/libs/core/langchain_core/callbacks/usage.py+++ b/libs/core/langchain_core/callbacks/usage.py@@ -24,7 +24,7 @@ class UsageMetadataCallbackHandler(BaseCallbackHandler):from langchain_core.callbacks import UsageMetadataCallbackHandlerllm_1 = init_chat_model(model="openai:gpt-4o-mini")- llm_2 = init_chat_model(model="anthropic:claude-3-5-haiku-latest")+ llm_2 = init_chat_model(model="anthropic:claude-3-5-haiku-20241022")callback = UsageMetadataCallbackHandler()result_1 = llm_1.invoke("Hello", config={"callbacks": [callback]})@@ -109,7 +109,7 @@ def get_usage_metadata_callback(from langchain_core.callbacks import get_usage_metadata_callbackllm_1 = init_chat_model(model="openai:gpt-4o-mini")- llm_2 = init_chat_model(model="anthropic:claude-3-5-haiku-latest")+ llm_2 = init_chat_model(model="anthropic:claude-3-5-haiku-20241022")with get_usage_metadata_callback() as cb:llm_1.invoke("Hello")diff --git a/libs/core/langchain_core/rate_limiters.py b/libs/core/langchain_core/rate_limiters.pyindex f347ded77f..986d3ff63b 100644--- a/libs/core/langchain_core/rate_limiters.py+++ b/libs/core/langchain_core/rate_limiters.py@@ -105,7 +105,9 @@ class InMemoryRateLimiter(BaseRateLimiter):from langchain_anthropic import ChatAnthropic- model = ChatAnthropic(model_name="claude-sonnet-4-5", rate_limiter=rate_limiter)+ model = ChatAnthropic(+ model_name="claude-sonnet-4-5-20250929", rate_limiter=rate_limiter+ )for _ in range(5):tic = time.time()diff --git a/libs/core/langchain_core/runnables/base.py b/libs/core/langchain_core/runnables/base.pyindex 9ca9321965..733e31b68b 100644--- a/libs/core/langchain_core/runnables/base.py+++ b/libs/core/langchain_core/runnables/base.py@@ -2637,7 +2637,7 @@ class RunnableSerializable(Serializable, Runnable[Input, Output]):from langchain_openai import ChatOpenAImodel = ChatAnthropic(- model_name="claude-3-7-sonnet-20250219"+ model_name="claude-sonnet-4-5-20250929").configurable_alternatives(ConfigurableField(id="llm"),default_key="anthropic",diff --git a/libs/core/langchain_core/runnables/fallbacks.py b/libs/core/langchain_core/runnables/fallbacks.pyindex 2e76a9b81f..9de53995d8 100644--- a/libs/core/langchain_core/runnables/fallbacks.py+++ b/libs/core/langchain_core/runnables/fallbacks.py@@ -604,7 +604,7 @@ class RunnableWithFallbacks(RunnableSerializable[Input, Output]):from langchain_anthropic import ChatAnthropicgpt_4o = ChatOpenAI(model="gpt-4o")- claude_3_sonnet = ChatAnthropic(model="claude-3-7-sonnet-20250219")+ claude_3_sonnet = ChatAnthropic(model="claude-sonnet-4-5-20250929")model = gpt_4o.with_fallbacks([claude_3_sonnet])model.model_namediff --git a/libs/langchain/langchain_classic/agents/tool_calling_agent/base.py b/libs/langchain/langchain_classic/agents/tool_calling_agent/base.pyindex d23ccb68cf..ad7ec028e4 100644--- a/libs/langchain/langchain_classic/agents/tool_calling_agent/base.py+++ b/libs/langchain/langchain_classic/agents/tool_calling_agent/base.py@@ -55,7 +55,7 @@ def create_tool_calling_agent(("placeholder", "{agent_scratchpad}"),])- model = ChatAnthropic(model="claude-3-opus-20240229")+ model = ChatAnthropic(model="claude-opus-4-1-20250805")@tooldef magic_function(input: int) -> int:diff --git a/libs/langchain/langchain_classic/chains/openai_functions/extraction.py b/libs/langchain/langchain_classic/chains/openai_functions/extraction.pyindex d8dadbf407..467ec63870 100644--- a/libs/langchain/langchain_classic/chains/openai_functions/extraction.py+++ b/libs/langchain/langchain_classic/chains/openai_functions/extraction.py@@ -66,7 +66,7 @@ Passage:# Please reference to the documentation of structured_output# to see an up to date list of which models support# with_structured_output.- model = ChatAnthropic(model="claude-3-opus-20240229", temperature=0)+ model = ChatAnthropic(model="claude-opus-4-1-20250805", temperature=0)structured_model = model.with_structured_output(Joke)structured_model.invoke("Tell me a joke about cats.Make sure to call the Joke function.")@@ -135,7 +135,7 @@ def create_extraction_chain(# Please reference to the documentation of structured_output# to see an up to date list of which models support# with_structured_output.- model = ChatAnthropic(model="claude-3-opus-20240229", temperature=0)+ model = ChatAnthropic(model="claude-opus-4-1-20250805", temperature=0)structured_model = model.with_structured_output(Joke)structured_model.invoke("Tell me a joke about cats.Make sure to call the Joke function.")diff --git a/libs/langchain/langchain_classic/chains/openai_functions/tagging.py b/libs/langchain/langchain_classic/chains/openai_functions/tagging.pyindex 99f84546a9..6c30b21cd0 100644--- a/libs/langchain/langchain_classic/chains/openai_functions/tagging.py+++ b/libs/langchain/langchain_classic/chains/openai_functions/tagging.py@@ -152,7 +152,7 @@ def create_tagging_chain_pydantic(# Please reference to the documentation of structured_output# to see an up to date list of which models support# with_structured_output.- model = ChatAnthropic(model="claude-3-opus-20240229", temperature=0)+ model = ChatAnthropic(model="claude-opus-4-1-20250805", temperature=0)structured_model = model.with_structured_output(Joke)structured_model.invoke("Why did the cat cross the road? To get to the other "diff --git a/libs/langchain/langchain_classic/chains/openai_tools/extraction.py b/libs/langchain/langchain_classic/chains/openai_tools/extraction.pyindex cad4467675..31460f401d 100644--- a/libs/langchain/langchain_classic/chains/openai_tools/extraction.py+++ b/libs/langchain/langchain_classic/chains/openai_tools/extraction.py@@ -43,7 +43,7 @@ If a property is not present and is not required in the function parameters, do# Please reference to the documentation of structured_output# to see an up to date list of which models support# with_structured_output.- model = ChatAnthropic(model="claude-3-opus-20240229", temperature=0)+ model = ChatAnthropic(model="claude-opus-4-1-20250805", temperature=0)structured_model = model.with_structured_output(Joke)structured_model.invoke("Tell me a joke about cats.Make sure to call the Joke function.")diff --git a/libs/langchain/langchain_classic/chains/structured_output/base.py b/libs/langchain/langchain_classic/chains/structured_output/base.pyindex 69f3ffd00c..93bd6156d5 100644--- a/libs/langchain/langchain_classic/chains/structured_output/base.py+++ b/libs/langchain/langchain_classic/chains/structured_output/base.py@@ -56,7 +56,7 @@ from pydantic import BaseModel# Please reference to the documentation of structured_output# to see an up to date list of which models support# with_structured_output.- model = ChatAnthropic(model="claude-3-opus-20240229", temperature=0)+ model = ChatAnthropic(model="claude-opus-4-1-20250805", temperature=0)structured_model = model.with_structured_output(Joke)structured_model.invoke("Tell me a joke about cats.Make sure to call the Joke function.")@@ -175,7 +175,7 @@ def create_openai_fn_runnable(# Please reference to the documentation of structured_output# to see an up to date list of which models support# with_structured_output.- model = ChatAnthropic(model="claude-3-opus-20240229", temperature=0)+ model = ChatAnthropic(model="claude-opus-4-1-20250805", temperature=0)structured_model = model.with_structured_output(Joke)structured_model.invoke("Tell me a joke about cats.Make sure to call the Joke function.")diff --git a/libs/langchain/langchain_classic/chat_models/base.py b/libs/langchain/langchain_classic/chat_models/base.pyindex 1ac5d4bdc0..b912f5189c 100644--- a/libs/langchain/langchain_classic/chat_models/base.py+++ b/libs/langchain/langchain_classic/chat_models/base.py@@ -96,7 +96,7 @@ def init_chat_model(for supported model parameters to use as `**kwargs`.Args:- model: The name of the model, e.g. `'o3-mini'`, `'claude-sonnet-4-5'`.+ model: The name or ID of the model, e.g. `'o3-mini'`, `'claude-sonnet-4-5-20250929'`.You can also specify model and model provider in a single argument using`'{model_provider}:{model}'` format, e.g. `'openai:o1'`.@@ -206,7 +206,7 @@ def init_chat_model(from langchain_classic.chat_models import init_chat_modelo3_mini = init_chat_model("openai:o3-mini", temperature=0)- claude_sonnet = init_chat_model("anthropic:claude-sonnet-4-5", temperature=0)+ claude_sonnet = init_chat_model("anthropic:claude-sonnet-4-5-20250929", temperature=0)gemini_2-5_flash = init_chat_model("google_vertexai:gemini-2.5-flash", temperature=0)@@ -233,7 +233,7 @@ def init_chat_model(configurable_model.invoke("what's your name",- config={"configurable": {"model": "claude-sonnet-4-5"}},+ config={"configurable": {"model": "claude-sonnet-4-5-20250929"}},)```@@ -258,7 +258,7 @@ def init_chat_model("what's your name",config={"configurable": {- "foo_model": "anthropic:claude-sonnet-4-5",+ "foo_model": "anthropic:claude-sonnet-4-5-20250929","foo_temperature": 0.6,}},@@ -311,7 +311,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"}},+ config={"configurable": {"model": "claude-sonnet-4-5-20250929"}},)# Use Sonnet 4.5```diff --git a/libs/langchain/tests/integration_tests/chat_models/test_base.py b/libs/langchain/tests/integration_tests/chat_models/test_base.pyindex eddc6cb45b..07c03b725e 100644--- a/libs/langchain/tests/integration_tests/chat_models/test_base.py+++ b/libs/langchain/tests/integration_tests/chat_models/test_base.py@@ -25,7 +25,7 @@ async def test_init_chat_model_chain() -> None:model_with_config = model_with_tools.with_config(RunnableConfig(tags=["foo"]),- configurable={"bar_model": "claude-3-7-sonnet-20250219"},+ configurable={"bar_model": "claude-sonnet-4-5-20250929"},)prompt = ChatPromptTemplate.from_messages([("system", "foo"), ("human", "{input}")])chain = prompt | model_with_configdiff --git a/libs/langchain/tests/unit_tests/chat_models/test_base.py b/libs/langchain/tests/unit_tests/chat_models/test_base.pyindex 400deabe9c..2b769aa4a3 100644--- a/libs/langchain/tests/unit_tests/chat_models/test_base.py+++ b/libs/langchain/tests/unit_tests/chat_models/test_base.py@@ -32,7 +32,7 @@ def test_all_imports() -> None:("model_name", "model_provider"),[("gpt-4o", "openai"),- ("claude-3-opus-20240229", "anthropic"),+ ("claude-opus-4-1", "anthropic"),("accounts/fireworks/models/mixtral-8x7b-instruct", "fireworks"),("mixtral-8x7b-32768", "groq"),],@@ -241,17 +241,17 @@ def test_configurable_with_default() -> None:model_with_config = model_with_tools.with_config(RunnableConfig(tags=["foo"]),- configurable={"bar_model": "claude-3-7-sonnet-20250219"},+ configurable={"bar_model": "claude-sonnet-4-5-20250929"},)- assert model_with_config.model == "claude-3-7-sonnet-20250219" # type: ignore[attr-defined]+ assert model_with_config.model == "claude-sonnet-4-5-20250929" # type: ignore[attr-defined]assert model_with_config.model_dump() == { # type: ignore[attr-defined]"name": None,"bound": {"name": None,"disable_streaming": False,- "model": "claude-3-7-sonnet-20250219",+ "model": "claude-sonnet-4-5-20250929","mcp_servers": None,"max_tokens": 64000,"temperature": None,diff --git a/libs/langchain_v1/langchain/agents/factory.py b/libs/langchain_v1/langchain/agents/factory.pyindex 3094261bd2..cdbb44db0d 100644--- a/libs/langchain_v1/langchain/agents/factory.py+++ b/libs/langchain_v1/langchain/agents/factory.py@@ -616,7 +616,7 @@ def create_agent( # noqa: PLR0915graph = create_agent(- model="anthropic:claude-sonnet-4-5",+ model="anthropic:claude-sonnet-4-5-20250929",tools=[check_weather],system_prompt="You are a helpful assistant",)diff --git a/libs/langchain_v1/langchain/agents/middleware/model_fallback.py b/libs/langchain_v1/langchain/agents/middleware/model_fallback.pyindex 88a7cdda49..6ac85e5775 100644--- a/libs/langchain_v1/langchain/agents/middleware/model_fallback.py+++ b/libs/langchain_v1/langchain/agents/middleware/model_fallback.py@@ -39,7 +39,7 @@ class ModelFallbackMiddleware(AgentMiddleware):middleware=[fallback],)- # If primary fails: tries gpt-4o-mini, then claude-3-5-sonnet+ # If primary fails: tries gpt-4o-mini, then claude-sonnet-4-5-20250929result = await agent.invoke({"messages": [HumanMessage("Hello")]})```"""diff --git a/libs/langchain_v1/langchain/agents/middleware/tool_emulator.py b/libs/langchain_v1/langchain/agents/middleware/tool_emulator.pyindex 93c3684a5f..90018150e4 100644--- a/libs/langchain_v1/langchain/agents/middleware/tool_emulator.py+++ b/libs/langchain_v1/langchain/agents/middleware/tool_emulator.py@@ -47,7 +47,9 @@ class LLMToolEmulator(AgentMiddleware):Use a custom model for emulation:```python- middleware = LLMToolEmulator(tools=["get_weather"], model="anthropic:claude-sonnet-4-5")+ middleware = LLMToolEmulator(+ tools=["get_weather"], model="anthropic:claude-sonnet-4-5-20250929"+ )```Emulate specific tools by passing tool instances:@@ -69,7 +71,7 @@ class LLMToolEmulator(AgentMiddleware):If None (default), ALL tools will be emulated.If empty list, no tools will be emulated.model: Model to use for emulation.- Defaults to "anthropic:claude-sonnet-4-5".+ Defaults to "anthropic:claude-sonnet-4-5-20250929".Can be a model identifier string or BaseChatModel instance."""super().__init__()@@ -89,7 +91,7 @@ class LLMToolEmulator(AgentMiddleware):# Initialize emulator modelif model is None:- self.model = init_chat_model("anthropic:claude-sonnet-4-5", temperature=1)+ self.model = init_chat_model("anthropic:claude-sonnet-4-5-20250929", temperature=1)elif isinstance(model, BaseChatModel):self.model = modelelse:diff --git a/libs/langchain_v1/langchain/chat_models/base.py b/libs/langchain_v1/langchain/chat_models/base.pyindex 43a6d38619..beeae9acab 100644--- a/libs/langchain_v1/langchain/chat_models/base.py+++ b/libs/langchain_v1/langchain/chat_models/base.py@@ -83,7 +83,7 @@ def init_chat_model(for supported model parameters to use as `**kwargs`.Args:- model: The name of the model, e.g. `'o3-mini'`, `'claude-sonnet-4-5'`.+ model: The name or ID of the model, e.g. `'o3-mini'`, `'claude-sonnet-4-5-20250929'`.You can also specify model and model provider in a single argument using`'{model_provider}:{model}'` format, e.g. `'openai:o1'`.@@ -193,7 +193,7 @@ def init_chat_model(from langchain.chat_models import init_chat_modelo3_mini = init_chat_model("openai:o3-mini", temperature=0)- claude_sonnet = init_chat_model("anthropic:claude-sonnet-4-5", temperature=0)+ claude_sonnet = init_chat_model("anthropic:claude-sonnet-4-5-20250929", temperature=0)gemini_2-5_flash = init_chat_model("google_vertexai:gemini-2.5-flash", temperature=0)o3_mini.invoke("what's your name")@@ -216,7 +216,7 @@ def init_chat_model(configurable_model.invoke("what's your name",- config={"configurable": {"model": "claude-sonnet-4-5"}},+ config={"configurable": {"model": "claude-sonnet-4-5-20250929"}},)```@@ -241,7 +241,7 @@ def init_chat_model("what's your name",config={"configurable": {- "foo_model": "anthropic:claude-sonnet-4-5",+ "foo_model": "anthropic:claude-sonnet-4-5-20250929","foo_temperature": 0.6,}},@@ -290,7 +290,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"}},+ config={"configurable": {"model": "claude-sonnet-4-5-20250929"}},)# Use Sonnet 4.5```diff --git a/libs/langchain_v1/tests/integration_tests/chat_models/test_base.py b/libs/langchain_v1/tests/integration_tests/chat_models/test_base.pyindex c2ebc5638e..ad0a90fa1d 100644--- a/libs/langchain_v1/tests/integration_tests/chat_models/test_base.py+++ b/libs/langchain_v1/tests/integration_tests/chat_models/test_base.py@@ -25,7 +25,7 @@ async def test_init_chat_model_chain() -> None:model_with_config = model_with_tools.with_config(RunnableConfig(tags=["foo"]),- configurable={"bar_model": "claude-3-7-sonnet-20250219"},+ configurable={"bar_model": "claude-sonnet-4-5-20250929"},)prompt = ChatPromptTemplate.from_messages([("system", "foo"), ("human", "{input}")])chain = prompt | model_with_configdiff --git a/libs/langchain_v1/tests/unit_tests/agents/middleware/test_tool_emulator.py b/libs/langchain_v1/tests/unit_tests/agents/middleware/test_tool_emulator.pyindex 1835b9772e..f522ca1648 100644--- a/libs/langchain_v1/tests/unit_tests/agents/middleware/test_tool_emulator.py+++ b/libs/langchain_v1/tests/unit_tests/agents/middleware/test_tool_emulator.py@@ -369,7 +369,9 @@ class TestLLMToolEmulatorModelConfiguration:"""Test passing a model string for emulation."""# Just test that initialization works - don't require anthropic packagetry:- emulator = LLMToolEmulator(tools=["get_weather"], model="anthropic:claude-sonnet-4-5")+ emulator = LLMToolEmulator(+ tools=["get_weather"], model="anthropic:claude-sonnet-4-5-20250929"+ )assert emulator.model is not Noneassert "get_weather" in emulator.tools_to_emulateexcept ImportError:diff --git a/libs/langchain_v1/tests/unit_tests/chat_models/test_chat_models.py b/libs/langchain_v1/tests/unit_tests/chat_models/test_chat_models.pyindex 75b0a86b12..9c1f6be555 100644--- a/libs/langchain_v1/tests/unit_tests/chat_models/test_chat_models.py+++ b/libs/langchain_v1/tests/unit_tests/chat_models/test_chat_models.py@@ -33,7 +33,7 @@ def test_all_imports() -> None:("model_name", "model_provider"),[("gpt-4o", "openai"),- ("claude-3-opus-20240229", "anthropic"),+ ("claude-opus-4-1", "anthropic"),("accounts/fireworks/models/mixtral-8x7b-instruct", "fireworks"),("mixtral-8x7b-32768", "groq"),],@@ -241,17 +241,17 @@ def test_configurable_with_default() -> None:model_with_config = model_with_tools.with_config(RunnableConfig(tags=["foo"]),- configurable={"bar_model": "claude-3-7-sonnet-20250219"},+ configurable={"bar_model": "claude-sonnet-4-5-20250929"},)- assert model_with_config.model == "claude-3-7-sonnet-20250219" # type: ignore[attr-defined]+ assert model_with_config.model == "claude-sonnet-4-5-20250929" # type: ignore[attr-defined]assert model_with_config.model_dump() == { # type: ignore[attr-defined]"name": None,"bound": {"name": None,"disable_streaming": False,- "model": "claude-3-7-sonnet-20250219",+ "model": "claude-sonnet-4-5-20250929","mcp_servers": None,"max_tokens": 64000,"temperature": None,