From 067cd73325ffb50bdca5f4570d5639c257264d1d Mon Sep 17 00:00:00 2001 From: CaptainB Date: Mon, 15 Dec 2025 11:33:55 +0800 Subject: [PATCH] chore: update agent configuration to include recursion limit in astream call --- apps/application/flow/tools.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/application/flow/tools.py b/apps/application/flow/tools.py index 6463848f2..f8b30c2b5 100644 --- a/apps/application/flow/tools.py +++ b/apps/application/flow/tools.py @@ -313,8 +313,9 @@ async def _yield_mcp_response(chat_model, message_list, mcp_servers, mcp_output_ try: client = MultiServerMCPClient(json.loads(mcp_servers)) tools = await client.get_tools() - agent = create_react_agent(chat_model, tools).configure(recursion_limit=(int(CONFIG.get("LANGCHAIN_GRAPH_RECURSION_LIMIT", '25')))) - response = agent.astream({"messages": message_list}, stream_mode='messages') + agent = create_react_agent(chat_model, tools) + recursion_limit = int(CONFIG.get("LANGCHAIN_GRAPH_RECURSION_LIMIT", '25')) + response = agent.astream({"messages": message_list}, config={"recursion_limit": recursion_limit}, stream_mode='messages') # 用于存储工具调用信息(按 tool_id)以及按 index 聚合分片 tool_calls_info = {}