From 6c091564ac3e5aabb02574305dd778d4c08cd743 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Sun, 17 May 2026 23:06:42 -0700 Subject: [PATCH] chore(core,langchain,openai): refresh stale OpenAI model references (#37487) --- libs/core/langchain_core/callbacks/usage.py | 34 +------------ libs/core/langchain_core/messages/utils.py | 2 +- .../langchain_core/output_parsers/string.py | 2 +- .../langchain_core/runnables/fallbacks.py | 8 ++-- libs/langchain_v1/langchain/agents/factory.py | 2 - .../langchain/agents/middleware/_retry.py | 6 ++- .../agents/middleware/model_call_limit.py | 2 +- .../agents/middleware/model_fallback.py | 6 +-- .../langchain/agents/middleware/pii.py | 6 +-- .../agents/middleware/summarization.py | 4 ++ .../langchain/agents/middleware/todo.py | 48 ++++++++++--------- .../agents/middleware/tool_call_limit.py | 9 ++-- .../agents/middleware/tool_emulator.py | 2 +- .../langchain/agents/middleware/tool_retry.py | 3 +- .../agents/middleware/tool_selection.py | 13 ++--- .../langchain/agents/middleware/types.py | 10 ++-- .../langchain/chat_models/base.py | 2 +- .../langchain_openai/chat_models/azure.py | 3 +- .../langchain_openai/chat_models/base.py | 4 +- .../langchain_openrouter/chat_models.py | 2 +- .../langchain_tests/unit_tests/chat_models.py | 2 +- 21 files changed, 73 insertions(+), 97 deletions(-) diff --git a/libs/core/langchain_core/callbacks/usage.py b/libs/core/langchain_core/callbacks/usage.py index ef1dd78e600..9fbcbb798db 100644 --- a/libs/core/langchain_core/callbacks/usage.py +++ b/libs/core/langchain_core/callbacks/usage.py @@ -23,7 +23,7 @@ class UsageMetadataCallbackHandler(BaseCallbackHandler): from langchain.chat_models import init_chat_model from langchain_core.callbacks import UsageMetadataCallbackHandler - llm_1 = init_chat_model(model="openai:gpt-4o-mini") + llm_1 = init_chat_model(model="openai:gpt-5.5") llm_2 = init_chat_model(model="anthropic:claude-haiku-4-5-20251001") callback = UsageMetadataCallbackHandler() @@ -32,18 +32,6 @@ class UsageMetadataCallbackHandler(BaseCallbackHandler): callback.usage_metadata ``` - ```txt - {'gpt-4o-mini-2024-07-18': {'input_tokens': 8, - 'output_tokens': 10, - 'total_tokens': 18, - 'input_token_details': {'audio': 0, 'cache_read': 0}, - 'output_token_details': {'audio': 0, 'reasoning': 0}}, - 'claude-haiku-4-5-20251001': {'input_tokens': 8, - 'output_tokens': 21, - 'total_tokens': 29, - 'input_token_details': {'cache_read': 0, 'cache_creation': 0}}} - ``` - !!! version-added "Added in `langchain-core` 0.3.49" """ @@ -109,7 +97,7 @@ def get_usage_metadata_callback( from langchain.chat_models import init_chat_model from langchain_core.callbacks import get_usage_metadata_callback - llm_1 = init_chat_model(model="openai:gpt-4o-mini") + llm_1 = init_chat_model(model="openai:gpt-5.5") llm_2 = init_chat_model(model="anthropic:claude-haiku-4-5-20251001") with get_usage_metadata_callback() as cb: @@ -118,24 +106,6 @@ def get_usage_metadata_callback( print(cb.usage_metadata) ``` - ```txt - { - "gpt-4o-mini-2024-07-18": { - "input_tokens": 8, - "output_tokens": 10, - "total_tokens": 18, - "input_token_details": {"audio": 0, "cache_read": 0}, - "output_token_details": {"audio": 0, "reasoning": 0}, - }, - "claude-haiku-4-5-20251001": { - "input_tokens": 8, - "output_tokens": 21, - "total_tokens": 29, - "input_token_details": {"cache_read": 0, "cache_creation": 0}, - }, - } - ``` - !!! version-added "Added in `langchain-core` 0.3.49" """ diff --git a/libs/core/langchain_core/messages/utils.py b/libs/core/langchain_core/messages/utils.py index faf27ccc4e4..69d8cc72b0b 100644 --- a/libs/core/langchain_core/messages/utils.py +++ b/libs/core/langchain_core/messages/utils.py @@ -1267,7 +1267,7 @@ def trim_messages( messages, max_tokens=45, strategy="last", - token_counter=ChatOpenAI(model="gpt-4o"), + token_counter=ChatOpenAI(model="openai:gpt-5.5"), # Most chat models expect that chat history starts with either: # (1) a HumanMessage or # (2) a SystemMessage followed by a HumanMessage diff --git a/libs/core/langchain_core/output_parsers/string.py b/libs/core/langchain_core/output_parsers/string.py index 0d8f3bb6edd..bd4c1fae754 100644 --- a/libs/core/langchain_core/output_parsers/string.py +++ b/libs/core/langchain_core/output_parsers/string.py @@ -19,7 +19,7 @@ class StrOutputParser(BaseTransformOutputParser[str]): from langchain_core.output_parsers import StrOutputParser from langchain_openai import ChatOpenAI - model = ChatOpenAI(model="gpt-4o") + model = ChatOpenAI(model="openai:gpt-5.5") parser = StrOutputParser() # Get string output from a model diff --git a/libs/core/langchain_core/runnables/fallbacks.py b/libs/core/langchain_core/runnables/fallbacks.py index 72fb6b4f693..16963722b26 100644 --- a/libs/core/langchain_core/runnables/fallbacks.py +++ b/libs/core/langchain_core/runnables/fallbacks.py @@ -605,16 +605,16 @@ class RunnableWithFallbacks(RunnableSerializable[Input, Output]): from langchain_openai import ChatOpenAI from langchain_anthropic import ChatAnthropic - gpt_4o = ChatOpenAI(model="gpt-4o") + gpt_55 = ChatOpenAI(model="openai:gpt-5.5") claude_3_sonnet = ChatAnthropic(model="claude-sonnet-4-5-20250929") - model = gpt_4o.with_fallbacks([claude_3_sonnet]) + model = gpt_55.with_fallbacks([claude_3_sonnet]) model.model_name - # -> "gpt-4o" + # -> "gpt-5.5" # .bind_tools() is called on both ChatOpenAI and ChatAnthropic # Equivalent to: - # gpt_4o.bind_tools([...]).with_fallbacks([claude_3_sonnet.bind_tools([...])]) + # gpt_55.bind_tools([...]).with_fallbacks([claude_3_sonnet.bind_tools([...])]) model.bind_tools([...]) # -> RunnableWithFallbacks( runnable=RunnableBinding(bound=ChatOpenAI(...), kwargs={"tools": [...]}), diff --git a/libs/langchain_v1/langchain/agents/factory.py b/libs/langchain_v1/langchain/agents/factory.py index c671b4ddb45..b66d650f3fd 100644 --- a/libs/langchain_v1/langchain/agents/factory.py +++ b/libs/langchain_v1/langchain/agents/factory.py @@ -155,8 +155,6 @@ FALLBACK_MODELS_WITH_STRUCTURED_OUTPUT = [ "gpt-4.1", "gpt-4o", "gpt-oss", - "o3-pro", - "o3-mini", ] diff --git a/libs/langchain_v1/langchain/agents/middleware/_retry.py b/libs/langchain_v1/langchain/agents/middleware/_retry.py index 961d00813ae..89665cc3289 100644 --- a/libs/langchain_v1/langchain/agents/middleware/_retry.py +++ b/libs/langchain_v1/langchain/agents/middleware/_retry.py @@ -26,8 +26,10 @@ Can be either: - A literal action string (`'error'` or `'continue'`) - `'error'`: Re-raise the exception, stopping agent execution. - `'continue'`: Inject a message with the error details, allowing the agent to continue. - For tool retries, a `ToolMessage` with the error details will be injected. - For model retries, an `AIMessage` with the error details will be returned. + + For tool retries, a `ToolMessage` with the error details will be injected. + + For model retries, an `AIMessage` with the error details will be returned. - A callable that takes an exception and returns a string for error message content """ diff --git a/libs/langchain_v1/langchain/agents/middleware/model_call_limit.py b/libs/langchain_v1/langchain/agents/middleware/model_call_limit.py index 48780c321cb..f0c31d4a518 100644 --- a/libs/langchain_v1/langchain/agents/middleware/model_call_limit.py +++ b/libs/langchain_v1/langchain/agents/middleware/model_call_limit.py @@ -114,7 +114,7 @@ class ModelCallLimitMiddleware( # Create middleware with limits call_tracker = ModelCallLimitMiddleware(thread_limit=10, run_limit=5, exit_behavior="end") - agent = create_agent("openai:gpt-4o", middleware=[call_tracker]) + agent = create_agent("openai:gpt-5.5", middleware=[call_tracker]) # Agent will automatically jump to end when limits are exceeded result = await agent.invoke({"messages": [HumanMessage("Help me with a task")]}) diff --git a/libs/langchain_v1/langchain/agents/middleware/model_fallback.py b/libs/langchain_v1/langchain/agents/middleware/model_fallback.py index dbf97274910..2bb60a2fd60 100644 --- a/libs/langchain_v1/langchain/agents/middleware/model_fallback.py +++ b/libs/langchain_v1/langchain/agents/middleware/model_fallback.py @@ -33,16 +33,16 @@ class ModelFallbackMiddleware(AgentMiddleware[AgentState[ResponseT], ContextT, R from langchain.agents import create_agent fallback = ModelFallbackMiddleware( - "openai:gpt-4o-mini", # Try first on error + "openai:gpt-5.5", # Try first on error "anthropic:claude-sonnet-4-5-20250929", # Then this ) agent = create_agent( - model="openai:gpt-4o", # Primary model + model="openai:gpt-5.5", # Primary model middleware=[fallback], ) - # If primary fails: tries gpt-4o-mini, then claude-sonnet-4-5-20250929 + # If primary fails: tries gpt-5.5, then claude-sonnet-4-5-20250929 result = await agent.invoke({"messages": [HumanMessage("Hello")]}) ``` """ diff --git a/libs/langchain_v1/langchain/agents/middleware/pii.py b/libs/langchain_v1/langchain/agents/middleware/pii.py index d15e682c259..a00c229a148 100644 --- a/libs/langchain_v1/langchain/agents/middleware/pii.py +++ b/libs/langchain_v1/langchain/agents/middleware/pii.py @@ -71,7 +71,7 @@ class PIIMiddleware(AgentMiddleware[AgentState[ResponseT], ContextT, ResponseT]) # Redact all emails in user input agent = create_agent( - "openai:gpt-5", + "openai:gpt-5.5", middleware=[ PIIMiddleware("email", strategy="redact"), ], @@ -79,7 +79,7 @@ class PIIMiddleware(AgentMiddleware[AgentState[ResponseT], ContextT, ResponseT]) # Use different strategies for different PII types agent = create_agent( - "openai:gpt-4o", + "openai:gpt-5.5", middleware=[ PIIMiddleware("credit_card", strategy="mask"), PIIMiddleware("url", strategy="redact"), @@ -89,7 +89,7 @@ class PIIMiddleware(AgentMiddleware[AgentState[ResponseT], ContextT, ResponseT]) # Custom PII type with regex agent = create_agent( - "openai:gpt-5", + "openai:gpt-5.5", middleware=[ PIIMiddleware("api_key", detector=r"sk-[a-zA-Z0-9]{32}", strategy="block"), ], diff --git a/libs/langchain_v1/langchain/agents/middleware/summarization.py b/libs/langchain_v1/langchain/agents/middleware/summarization.py index ac31da5b299..718b83f9a5f 100644 --- a/libs/langchain_v1/langchain/agents/middleware/summarization.py +++ b/libs/langchain_v1/langchain/agents/middleware/summarization.py @@ -50,15 +50,19 @@ You want to ensure that you don't repeat any actions you've already completed, s You should structure your summary using the following sections. Each section acts as a checklist - you must populate it with relevant information or explicitly state "None" if there is nothing to report for that section: ## SESSION INTENT + What is the user's primary goal or request? What overall task are you trying to accomplish? This should be concise but complete enough to understand the purpose of the entire session. ## SUMMARY + Extract and record all of the most important context from the conversation history. Include important choices, conclusions, or strategies determined during this conversation. Include the reasoning behind key decisions. Document any rejected options and why they were not pursued. ## ARTIFACTS + What artifacts, files, or resources were created, modified, or accessed during this conversation? For file modifications, list specific file paths and briefly describe the changes made to each. This section prevents silent loss of artifact information. ## NEXT STEPS + What specific tasks remain to be completed to achieve the session intent? What should you do next? diff --git a/libs/langchain_v1/langchain/agents/middleware/todo.py b/libs/langchain_v1/langchain/agents/middleware/todo.py index ae1975d191b..2cb0b94154f 100644 --- a/libs/langchain_v1/langchain/agents/middleware/todo.py +++ b/libs/langchain_v1/langchain/agents/middleware/todo.py @@ -54,6 +54,7 @@ WRITE_TODOS_TOOL_DESCRIPTION = """Use this tool to create and manage a structure Only use this tool if you think it will be helpful in staying organized. If the user's request is trivial and takes less than 3 steps, it is better to NOT use this tool and just do the task directly. ## When to Use This Tool + Use this tool in these scenarios: 1. Complex multi-step tasks - When a task requires 3 or more distinct steps or actions @@ -63,12 +64,14 @@ Use this tool in these scenarios: 5. The plan may need future revisions or updates based on results from the first few steps ## How to Use This Tool + 1. When you start working on a task - Mark it as in_progress BEFORE beginning work. 2. After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation. 3. You can also update future tasks, such as deleting them if they are no longer necessary, or adding new tasks that are necessary. Don't change previously completed tasks. 4. You can make several updates to the todo list at once. For example, when you complete a task, you can mark the next task you need to start as in_progress. ## When NOT to Use This Tool + It is important to skip using this tool when: 1. There is only a single, straightforward task 2. The task is trivial and tracking it provides no benefit @@ -78,33 +81,33 @@ It is important to skip using this tool when: ## Task States and Management 1. **Task States**: Use these states to track progress: - - pending: Task not yet started - - in_progress: Currently working on (you can have multiple tasks in_progress at a time if they are not related to each other and can be run in parallel) - - completed: Task finished successfully + - pending: Task not yet started + - in_progress: Currently working on (you can have multiple tasks in_progress at a time if they are not related to each other and can be run in parallel) + - completed: Task finished successfully 2. **Task Management**: - - Update task status in real-time as you work - - Mark tasks complete IMMEDIATELY after finishing (don't batch completions) - - Complete current tasks before starting new ones - - Remove tasks that are no longer relevant from the list entirely - - IMPORTANT: When you write this todo list, you should mark your first task (or tasks) as in_progress immediately!. - - IMPORTANT: Unless all tasks are completed, you should always have at least one task in_progress to show the user that you are working on something. + - Update task status in real-time as you work + - Mark tasks complete IMMEDIATELY after finishing (don't batch completions) + - Complete current tasks before starting new ones + - Remove tasks that are no longer relevant from the list entirely + - IMPORTANT: When you write this todo list, you should mark your first task (or tasks) as in_progress immediately!. + - IMPORTANT: Unless all tasks are completed, you should always have at least one task in_progress to show the user that you are working on something. 3. **Task Completion Requirements**: - - ONLY mark a task as completed when you have FULLY accomplished it - - If you encounter errors, blockers, or cannot finish, keep the task as in_progress - - When blocked, create a new task describing what needs to be resolved - - Never mark a task as completed if: - - There are unresolved issues or errors - - Work is partial or incomplete - - You encountered blockers that prevent completion - - You couldn't find necessary resources or dependencies - - Quality standards haven't been met + - ONLY mark a task as completed when you have FULLY accomplished it + - If you encounter errors, blockers, or cannot finish, keep the task as in_progress + - When blocked, create a new task describing what needs to be resolved + - Never mark a task as completed if: + - There are unresolved issues or errors + - Work is partial or incomplete + - You encountered blockers that prevent completion + - You couldn't find necessary resources or dependencies + - Quality standards haven't been met 4. **Task Breakdown**: - - Create specific, actionable items - - Break complex tasks into smaller, manageable steps - - Use clear, descriptive task names + - Create specific, actionable items + - Break complex tasks into smaller, manageable steps + - Use clear, descriptive task names Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully Remember: If you only need to make a few tool calls to complete a task, and it is clear what you need to do, it is better to just do the task directly and NOT call this tool at all.""" # noqa: E501 @@ -120,6 +123,7 @@ For simple objectives that only require a few steps, it is better to just comple Writing todos takes time and tokens, use it when it is helpful for managing complex many-step problems! But not for simple few-step requests. ## Important To-Do List Usage Notes to Remember + - The `write_todos` tool should never be called multiple times in parallel. - Don't be afraid to revise the To-Do list as you go. New information may reveal new tasks that need to be done, or old tasks that are irrelevant.""" # noqa: E501 @@ -177,7 +181,7 @@ class TodoListMiddleware(AgentMiddleware[PlanningState[ResponseT], ContextT, Res from langchain.agents.middleware import TodoListMiddleware from langchain.agents import create_agent - agent = create_agent("openai:gpt-4o", middleware=[TodoListMiddleware()]) + agent = create_agent("openai:gpt-5.5", middleware=[TodoListMiddleware()]) # Agent now has access to write_todos tool and todo state tracking result = await agent.invoke({"messages": [HumanMessage("Help me refactor my codebase")]}) diff --git a/libs/langchain_v1/langchain/agents/middleware/tool_call_limit.py b/libs/langchain_v1/langchain/agents/middleware/tool_call_limit.py index 503205866ad..1dfc5e4e6e7 100644 --- a/libs/langchain_v1/langchain/agents/middleware/tool_call_limit.py +++ b/libs/langchain_v1/langchain/agents/middleware/tool_call_limit.py @@ -166,7 +166,7 @@ class ToolCallLimitMiddleware(AgentMiddleware[ToolCallLimitState[ResponseT], Con exit_behavior="continue", # default ) - agent = create_agent("openai:gpt-4o", middleware=[limiter]) + agent = create_agent("openai:gpt-5.5", middleware=[limiter]) ``` !!! example "Stop immediately when limit exceeded" @@ -175,7 +175,7 @@ class ToolCallLimitMiddleware(AgentMiddleware[ToolCallLimitState[ResponseT], Con # End execution immediately with an AI message limiter = ToolCallLimitMiddleware(run_limit=5, exit_behavior="end") - agent = create_agent("openai:gpt-4o", middleware=[limiter]) + agent = create_agent("openai:gpt-5.5", middleware=[limiter]) ``` !!! example "Raise exception on limit" @@ -186,7 +186,7 @@ class ToolCallLimitMiddleware(AgentMiddleware[ToolCallLimitState[ResponseT], Con tool_name="search", thread_limit=5, exit_behavior="error" ) - agent = create_agent("openai:gpt-4o", middleware=[limiter]) + agent = create_agent("openai:gpt-5.5", middleware=[limiter]) try: result = await agent.invoke({"messages": [HumanMessage("Task")]}) @@ -300,8 +300,7 @@ class ToolCallLimitMiddleware(AgentMiddleware[ToolCallLimitState[ResponseT], Con run_count: Current run call count. Returns: - Tuple of `(allowed_calls, blocked_calls, final_thread_count, - final_run_count)`. + Tuple of `(allowed_calls, blocked_calls, final_thread_count, final_run_count)`. """ allowed_calls: list[ToolCall] = [] blocked_calls: list[ToolCall] = [] diff --git a/libs/langchain_v1/langchain/agents/middleware/tool_emulator.py b/libs/langchain_v1/langchain/agents/middleware/tool_emulator.py index c5605f40af0..61dfcb7e114 100644 --- a/libs/langchain_v1/langchain/agents/middleware/tool_emulator.py +++ b/libs/langchain_v1/langchain/agents/middleware/tool_emulator.py @@ -36,7 +36,7 @@ class LLMToolEmulator(AgentMiddleware[AgentState[Any], ContextT], Generic[Contex middleware = LLMToolEmulator() agent = create_agent( - model="openai:gpt-4o", + model="openai:gpt-5.5", tools=[get_weather, get_user_location, calculator], middleware=[middleware], ) diff --git a/libs/langchain_v1/langchain/agents/middleware/tool_retry.py b/libs/langchain_v1/langchain/agents/middleware/tool_retry.py index c6fa238eabf..bfb55bd9a4a 100644 --- a/libs/langchain_v1/langchain/agents/middleware/tool_retry.py +++ b/libs/langchain_v1/langchain/agents/middleware/tool_retry.py @@ -352,8 +352,7 @@ class ToolRetryMiddleware(AgentMiddleware[AgentState[ResponseT], ContextT, Respo Args: request: Tool call request with call `dict`, `BaseTool`, state, and runtime. - handler: Async callable to execute the tool and returns `ToolMessage` or - `Command`. + handler: Async callable to execute the tool and returns `ToolMessage` or `Command`. Returns: `ToolMessage` or `Command` (the final result). diff --git a/libs/langchain_v1/langchain/agents/middleware/tool_selection.py b/libs/langchain_v1/langchain/agents/middleware/tool_selection.py index f046ac8adac..98cf01e4b52 100644 --- a/libs/langchain_v1/langchain/agents/middleware/tool_selection.py +++ b/libs/langchain_v1/langchain/agents/middleware/tool_selection.py @@ -106,7 +106,7 @@ class LLMToolSelectorMiddleware(AgentMiddleware[AgentState[ResponseT], ContextT, middleware = LLMToolSelectorMiddleware(max_tools=3) agent = create_agent( - model="openai:gpt-4o", + model="openai:gpt-5.5", tools=[tool1, tool2, tool3, tool4, tool5], middleware=[middleware], ) @@ -115,7 +115,7 @@ class LLMToolSelectorMiddleware(AgentMiddleware[AgentState[ResponseT], ContextT, !!! example "Use a smaller model for selection" ```python - middleware = LLMToolSelectorMiddleware(model="openai:gpt-4o-mini", max_tools=2) + middleware = LLMToolSelectorMiddleware(model="openai:gpt-5.4-mini", max_tools=2) ``` """ @@ -164,8 +164,7 @@ class LLMToolSelectorMiddleware(AgentMiddleware[AgentState[ResponseT], ContextT, request: the model request. Returns: - `SelectionRequest` with prepared inputs, or `None` if no selection is - needed. + `SelectionRequest` with prepared inputs, or `None` if no selection is needed. Raises: ValueError: If tools in `always_include` are not found in the request. @@ -280,8 +279,7 @@ class LLMToolSelectorMiddleware(AgentMiddleware[AgentState[ResponseT], ContextT, Args: request: Model request to execute (includes state and runtime). - handler: Async callback that executes the model request and returns - `ModelResponse`. + handler: Async callback that executes the model request and returns `ModelResponse`. Returns: The model call result. @@ -323,8 +321,7 @@ class LLMToolSelectorMiddleware(AgentMiddleware[AgentState[ResponseT], ContextT, Args: request: Model request to execute (includes state and runtime). - handler: Async callback that executes the model request and returns - `ModelResponse`. + handler: Async callback that executes the model request and returns `ModelResponse`. Returns: The model call result. diff --git a/libs/langchain_v1/langchain/agents/middleware/types.py b/libs/langchain_v1/langchain/agents/middleware/types.py index fbf3ce1b89f..c249d17465f 100644 --- a/libs/langchain_v1/langchain/agents/middleware/types.py +++ b/libs/langchain_v1/langchain/agents/middleware/types.py @@ -90,7 +90,9 @@ class ModelRequest(Generic[ContextT]): """Model request information for the agent. Type Parameters: - ContextT: The type of the runtime context. Defaults to `None` if not specified. + ContextT: The type of the runtime context. + + Defaults to `None` if not specified. """ model: BaseChatModel @@ -117,7 +119,7 @@ class ModelRequest(Generic[ContextT]): runtime: Runtime[ContextT] | None = None, model_settings: dict[str, Any] | None = None, ) -> None: - """Initialize ModelRequest with backward compatibility for system_prompt. + """Initialize `ModelRequest` with backward compatibility for `system_prompt`. Args: model: The chat model to use. @@ -129,7 +131,7 @@ class ModelRequest(Generic[ContextT]): runtime: Runtime context. model_settings: Additional model settings. system_message: System message instance (preferred). - system_prompt: System prompt string (deprecated, converted to SystemMessage). + system_prompt: System prompt string (deprecated, converted to `SystemMessage`). Raises: ValueError: If both `system_prompt` and `system_message` are provided. @@ -245,7 +247,7 @@ class ModelRequest(Generic[ContextT]): ```python new_request = request.override( - model=ChatOpenAI(model="gpt-4o"), + model=ChatOpenAI(model="gpt-5.5"), system_message=SystemMessage(content="New instructions"), ) ``` diff --git a/libs/langchain_v1/langchain/chat_models/base.py b/libs/langchain_v1/langchain/chat_models/base.py index 490535d0c28..b210d1c74c6 100644 --- a/libs/langchain_v1/langchain/chat_models/base.py +++ b/libs/langchain_v1/langchain/chat_models/base.py @@ -474,7 +474,7 @@ def init_chat_model( """ # noqa: E501 if model is not None and not isinstance(model, str): msg = ( # type: ignore[unreachable] - f"`model` must be a string (e.g., 'openai:gpt-4o'), got " + f"`model` must be a string (e.g., 'openai:gpt-5.5'), got " f"{type(model).__name__}. If you've already constructed a chat model " f"object, use it directly instead of passing it to init_chat_model()." ) diff --git a/libs/partners/openai/langchain_openai/chat_models/azure.py b/libs/partners/openai/langchain_openai/chat_models/azure.py index 797901cfd2b..68bf75856ce 100644 --- a/libs/partners/openai/langchain_openai/chat_models/azure.py +++ b/libs/partners/openai/langchain_openai/chat_models/azure.py @@ -539,12 +539,13 @@ class AzureChatOpenAI(BaseChatOpenAI): """ model_name: str | None = Field(default=None, alias="model") # type: ignore[assignment] - """Name of the deployed OpenAI model, e.g. `'gpt-4o'`, `'gpt-35-turbo'`, etc. + """Name of the deployed OpenAI model. Distinct from the Azure deployment name, which is set by the Azure user. Used for tracing and token counting. !!! warning + Does NOT affect completion. """ diff --git a/libs/partners/openai/langchain_openai/chat_models/base.py b/libs/partners/openai/langchain_openai/chat_models/base.py index 4b7b5bd8ec1..8e2473fe221 100644 --- a/libs/partners/openai/langchain_openai/chat_models/base.py +++ b/libs/partners/openai/langchain_openai/chat_models/base.py @@ -2323,7 +2323,7 @@ class BaseChatOpenAI(BaseChatModel): \"\"\"Get weather at a location.\"\"\" pass - model = init_chat_model("openai:gpt-4o-mini") + model = init_chat_model("openai:gpt-5.5") structured_model = model.with_structured_output( ResponseSchema, @@ -3472,7 +3472,7 @@ class ChatOpenAI(BaseChatOpenAI): # type: ignore[override] \"\"\"Get weather at a location.\"\"\" pass - model = init_chat_model("openai:gpt-4o-mini") + model = init_chat_model("openai:gpt-5.5") structured_model = model.with_structured_output( ResponseSchema, diff --git a/libs/partners/openrouter/langchain_openrouter/chat_models.py b/libs/partners/openrouter/langchain_openrouter/chat_models.py index 1a5d3cecb7a..b0ef381fbb4 100644 --- a/libs/partners/openrouter/langchain_openrouter/chat_models.py +++ b/libs/partners/openrouter/langchain_openrouter/chat_models.py @@ -105,7 +105,7 @@ class ChatOpenRouter(BaseChatModel): | Param | Type | Description | | ----- | ---- | ----------- | - | `model` | `str` | Model name, e.g. `'openai/gpt-4o-mini'`. | + | `model` | `str` | Model name | | `temperature` | `float | None` | Sampling temperature. | | `max_tokens` | `int | None` | Max tokens to generate. | diff --git a/libs/standard-tests/langchain_tests/unit_tests/chat_models.py b/libs/standard-tests/langchain_tests/unit_tests/chat_models.py index 9176c876401..c2c854a94af 100644 --- a/libs/standard-tests/langchain_tests/unit_tests/chat_models.py +++ b/libs/standard-tests/langchain_tests/unit_tests/chat_models.py @@ -721,7 +721,7 @@ class ChatModelUnitTests(ChatModelTests): ```python @property def model_override_value(self) -> str: - return "gpt-4o-mini" # e.g. if default is "gpt-4o" + return "gpt-5.4-mini" # e.g. if default is "gpt-5.5" ``` ??? info "`enable_vcr_tests`"