diff --git a/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py b/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py index ac2f27ac0..06a554d62 100644 --- a/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py +++ b/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py @@ -13,7 +13,6 @@ from typing import ( cast, get_type_hints, ) -from warnings import warn from langchain_core.language_models import ( BaseChatModel, @@ -36,7 +35,6 @@ from pydantic import BaseModel from typing_extensions import Annotated, NotRequired, TypedDict, TypeVar from langgraph._internal._runnable import RunnableCallable, RunnableLike -from langgraph._internal._typing import MISSING from langgraph.errors import ErrorCode, create_error_message from langgraph.graph import END, StateGraph from langgraph.graph.message import add_messages @@ -55,7 +53,6 @@ from langgraph.runtime import Runtime from langgraph.store.base import BaseStore from langgraph.types import Checkpointer, Command, Send from langgraph.typing import ContextT -from langgraph.warnings import LangGraphDeprecatedSinceV10 F = TypeVar("F", bound=Callable[..., Any]) @@ -783,7 +780,9 @@ def create_react_agent( tools: Union[Sequence[Union[BaseTool, Callable, dict[str, Any]]], ToolNode], *, prompt: Optional[Prompt] = None, - response_format: Optional[Union[ToolOutput, type[StructuredResponseT]]] = None, + response_format: Optional[ + Union[ToolOutput[StructuredResponseT], type[StructuredResponseT]] + ] = None, pre_model_hook: Optional[RunnableLike] = None, post_model_hook: Optional[RunnableLike] = None, state_schema: Optional[StateSchemaType] = None, @@ -794,7 +793,6 @@ def create_react_agent( interrupt_after: Optional[list[str]] = None, debug: bool = False, name: Optional[str] = None, - **deprecated_kwargs: Any, ) -> CompiledStateGraph: """Creates an agent graph that calls tools in a loop until a stopping condition is met. @@ -923,13 +921,8 @@ def create_react_agent( This name will be automatically used when adding ReAct agent graph to another graph as a subgraph node - particularly useful for building multi-agent systems. - !!! warning "`config_schema` Deprecated" - The `config_schema` parameter is deprecated in v0.6.0 and support will be removed in v2.0.0. - Please use `context_schema` instead to specify the schema for run-scoped context. - - Returns: - A compiled LangChain runnable that can be used for chat interactions. + A CompiledStateGraph that can be used for chat interactions. The "agent" node calls the language model with the messages list (after applying the prompt). If the resulting AIMessage contains `tool_calls`, the graph will then call the ["tools"][langgraph.prebuilt.tool_node.ToolNode]. @@ -970,22 +963,6 @@ def create_react_agent( print(chunk) ``` """ - # Handle deprecated config_schema parameter - if ( - config_schema := deprecated_kwargs.pop("config_schema", MISSING) - ) is not MISSING: - warn( - "`config_schema` is deprecated and will be removed. Please use `context_schema` instead.", - category=LangGraphDeprecatedSinceV10, - ) - if context_schema is None: - context_schema = config_schema - - if len(deprecated_kwargs) > 0: - raise TypeError( - f"create_react_agent() got unexpected keyword arguments: {deprecated_kwargs}" - ) - if response_format and not isinstance(response_format, ToolOutput): # Then it's a pydantic model or JSONSchema. We'll automatically convert # it to the tool output strategy as it is widely supported. diff --git a/libs/prebuilt/tests/test_deprecation.py b/libs/prebuilt/tests/test_deprecation.py deleted file mode 100644 index 63e9e9b2e..000000000 --- a/libs/prebuilt/tests/test_deprecation.py +++ /dev/null @@ -1,41 +0,0 @@ -import pytest -from typing_extensions import TypedDict - -from langgraph.prebuilt import create_react_agent -from langgraph.warnings import LangGraphDeprecatedSinceV10 -from tests.model import FakeToolCallingModel - - -class Config(TypedDict): - model: str - - -@pytest.mark.filterwarnings("ignore:`config_schema` is deprecated") -@pytest.mark.filterwarnings("ignore:`get_config_jsonschema` is deprecated") -def test_config_schema_deprecation() -> None: - with pytest.warns( - LangGraphDeprecatedSinceV10, - match="`config_schema` is deprecated and will be removed. Please use `context_schema` instead.", - ): - agent = create_react_agent(FakeToolCallingModel(), [], config_schema=Config) - assert agent.context_schema == Config - - with pytest.warns( - LangGraphDeprecatedSinceV10, - match="`config_schema` is deprecated. Use `get_context_jsonschema` for the relevant schema instead.", - ): - assert agent.config_schema() is not None - - with pytest.warns( - LangGraphDeprecatedSinceV10, - match="`get_config_jsonschema` is deprecated. Use `get_context_jsonschema` instead.", - ): - assert agent.get_config_jsonschema() is not None - - -def test_extra_kwargs_deprecation() -> None: - with pytest.raises( - TypeError, - match="create_react_agent\(\) got unexpected keyword arguments: \{'extra': 'extra'\}", - ): - create_react_agent(FakeToolCallingModel(), [], extra="extra")