From 01e7d027fc3f110f32e8222419a4d416de96a637 Mon Sep 17 00:00:00 2001 From: "open-swe[bot]" Date: Mon, 11 Aug 2025 20:28:47 +0000 Subject: [PATCH] Apply patch [skip ci] --- .../langgraph/prebuilt/chat_agent_executor.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py b/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py index 5b089078f..60e775fca 100644 --- a/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py +++ b/libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py @@ -868,7 +868,21 @@ def create_react_agent( break if response_tool_call is None: - raise ValueError(f"Expected tool call with name '{response_tool_name}'") + # No response schema tool call found, but there are other tool calls + # This shouldn't happen in normal flow, fall back to old behavior + structured_response_schema = response_format + if isinstance(response_format, tuple): + system_prompt, structured_response_schema = response_format + messages = [SystemMessage(content=system_prompt)] + list(messages) + + resolved_model = await _aresolve_model(state, runtime) + model_with_structured_output = _get_model( + resolved_model + ).with_structured_output( + cast(StructuredResponseSchema, structured_response_schema) + ) + response = await model_with_structured_output.ainvoke(messages, config) + return {"structured_response": response} # Extract the actual schema from tuple if needed actual_schema = response_format @@ -1139,3 +1153,4 @@ __all__ = [ +