From 0171e9a323404301711c4405489d83ca55ea29aa Mon Sep 17 00:00:00 2001 From: Sydney Runkle <54324534+sydney-runkle@users.noreply.github.com> Date: Fri, 13 Jun 2025 12:34:39 -0400 Subject: [PATCH] fix(langgraph): remove deprecated `output` usage in favor of `output_schema` (#5095) use output_schema --- libs/langgraph/tests/test_large_cases.py | 2 +- .../langgraph/tests/test_large_cases_async.py | 2 +- libs/langgraph/tests/test_pregel_async.py | 26 ++++++++++++------- libs/langgraph/tests/test_state.py | 2 +- libs/prebuilt/tests/test_react_agent.py | 7 +++-- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/libs/langgraph/tests/test_large_cases.py b/libs/langgraph/tests/test_large_cases.py index 04ff8e5c6..509059251 100644 --- a/libs/langgraph/tests/test_large_cases.py +++ b/libs/langgraph/tests/test_large_cases.py @@ -4326,7 +4326,7 @@ def test_send_to_nested_graphs(sync_checkpointer: BaseCheckpointSaver) -> None: return {"subject": f"{subject} - hohoho"} # subgraph - subgraph = StateGraph(JokeState, output=OverallState) + subgraph = StateGraph(JokeState, output_schema=OverallState) subgraph.add_node("edit", edit) subgraph.add_node( "generate", lambda state: {"jokes": [f"Joke about {state['subject']}"]} diff --git a/libs/langgraph/tests/test_large_cases_async.py b/libs/langgraph/tests/test_large_cases_async.py index b144e89e7..90d1a0c33 100644 --- a/libs/langgraph/tests/test_large_cases_async.py +++ b/libs/langgraph/tests/test_large_cases_async.py @@ -3145,7 +3145,7 @@ async def test_send_to_nested_graphs(async_checkpointer: BaseCheckpointSaver) -> return {"subject": f"{subject} - hohoho"} # subgraph - subgraph = StateGraph(JokeState, output=OverallState) + subgraph = StateGraph(JokeState, output_schema=OverallState) subgraph.add_node("edit", edit) subgraph.add_node( "generate", lambda state: {"jokes": [f"Joke about {state['subject']}"]} diff --git a/libs/langgraph/tests/test_pregel_async.py b/libs/langgraph/tests/test_pregel_async.py index c536fcdbf..f7934a9f5 100644 --- a/libs/langgraph/tests/test_pregel_async.py +++ b/libs/langgraph/tests/test_pregel_async.py @@ -1338,7 +1338,7 @@ async def test_node_schemas_custom_output() -> None: "now": 123, } - builder = StateGraph(State, output=Output) + builder = StateGraph(State, output_schema=Output) builder.add_node("a", node_a) builder.add_node("b", node_b) builder.add_node("c", node_c) @@ -1353,7 +1353,7 @@ async def test_node_schemas_custom_output() -> None: "messages": [_AnyIdHumanMessage(content="hello")], } - builder = StateGraph(State, output=Output) + builder = StateGraph(State, output_schema=Output) builder.add_node("a", node_a) builder.add_node("b", node_b) builder.add_node("c", node_c) @@ -7030,14 +7030,17 @@ async def test_multiple_subgraphs(async_checkpointer: BaseCheckpointSaver) -> No return {"result": state["a"] + state["b"]} add_subgraph = ( - StateGraph(State, output=Output).add_node(add).add_edge(START, "add").compile() + StateGraph(State, output_schema=Output) + .add_node(add) + .add_edge(START, "add") + .compile() ) async def multiply(state): return {"result": state["a"] * state["b"]} multiply_subgraph = ( - StateGraph(State, output=Output) + StateGraph(State, output_schema=Output) .add_node(multiply) .add_edge(START, "multiply") .compile() @@ -7050,7 +7053,7 @@ async def test_multiple_subgraphs(async_checkpointer: BaseCheckpointSaver) -> No return another_result parent_call_same_subgraph = ( - StateGraph(State, output=Output) + StateGraph(State, output_schema=Output) .add_node(call_same_subgraph) .add_edge(START, "call_same_subgraph") .compile(checkpointer=async_checkpointer) @@ -7074,7 +7077,7 @@ async def test_multiple_subgraphs(async_checkpointer: BaseCheckpointSaver) -> No } parent_call_multiple_subgraphs = ( - StateGraph(State, output=Output) + StateGraph(State, output_schema=Output) .add_node(call_multiple_subgraphs) .add_edge(START, "call_multiple_subgraphs") .compile(checkpointer=async_checkpointer) @@ -7152,14 +7155,17 @@ async def test_multiple_subgraphs_mixed_entrypoint( return {"result": state["a"] + state["b"]} add_subgraph = ( - StateGraph(State, output=Output).add_node(add).add_edge(START, "add").compile() + StateGraph(State, output_schema=Output) + .add_node(add) + .add_edge(START, "add") + .compile() ) async def multiply(state): return {"result": state["a"] * state["b"]} multiply_subgraph = ( - StateGraph(State, output=Output) + StateGraph(State, output_schema=Output) .add_node(multiply) .add_edge(START, "multiply") .compile() @@ -7229,7 +7235,7 @@ async def test_multiple_subgraphs_mixed_state_graph( return {"result": another_result} parent_call_same_subgraph = ( - StateGraph(State, output=Output) + StateGraph(State, output_schema=Output) .add_node(call_same_subgraph) .add_edge(START, "call_same_subgraph") .compile(checkpointer=async_checkpointer) @@ -7253,7 +7259,7 @@ async def test_multiple_subgraphs_mixed_state_graph( } parent_call_multiple_subgraphs = ( - StateGraph(State, output=Output) + StateGraph(State, output_schema=Output) .add_node(call_multiple_subgraphs) .add_edge(START, "call_multiple_subgraphs") .compile(checkpointer=async_checkpointer) diff --git a/libs/langgraph/tests/test_state.py b/libs/langgraph/tests/test_state.py index fe1958b08..0ad70140d 100644 --- a/libs/langgraph/tests/test_state.py +++ b/libs/langgraph/tests/test_state.py @@ -92,7 +92,7 @@ def test_state_schema_with_type_hint(): assert state.pop("foo") == "bar" return {"input_state": state} - graph = StateGraph(InputState, output=OutputState) + graph = StateGraph(InputState, output_schema=OutputState) actions = [ complete_hint, miss_first_hint, diff --git a/libs/prebuilt/tests/test_react_agent.py b/libs/prebuilt/tests/test_react_agent.py index a6ee21c45..fc0436a3a 100644 --- a/libs/prebuilt/tests/test_react_agent.py +++ b/libs/prebuilt/tests/test_react_agent.py @@ -1089,14 +1089,17 @@ def test_react_with_subgraph_tools( return {"result": state["a"] + state["b"]} add_subgraph = ( - StateGraph(State, output=Output).add_node(add).add_edge(START, "add").compile() + StateGraph(State, output_schema=Output) + .add_node(add) + .add_edge(START, "add") + .compile() ) def multiply(state): return {"result": state["a"] * state["b"]} multiply_subgraph = ( - StateGraph(State, output=Output) + StateGraph(State, output_schema=Output) .add_node(multiply) .add_edge(START, "multiply") .compile()