From 711a03e898dfa0572d2dc03a71499578f848eea2 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Thu, 1 Oct 2026 10:40:31 +0200 Subject: [PATCH] fix(agent): Raise recursion_limit to allow more tool calls per interaction Signed-off-by: Marcel Klehr --- ex_app/lib/agent.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ex_app/lib/agent.py b/ex_app/lib/agent.py index 779b108b..90ead512 100644 --- a/ex_app/lib/agent.py +++ b/ex_app/lib/agent.py @@ -29,8 +29,12 @@ from ex_app.lib.signature import add_signature, verify_signature from ex_app.lib.tools import get_tools -# Dummy thread id as we return the whole state -thread = {"configurable": {"thread_id": "thread-1"}} +graph_config = { + # Dummy thread id as we return the whole state + "configurable": {"thread_id": "thread-1"}, + # Maximum amount of tool calls per interaction + "recursion_limit": 256 +} key_file_path = persistent_storage() + '/secret_key.txt' @@ -206,7 +210,7 @@ async def call_model( graph = await get_graph(call_model, safe_tools, dangerous_tools, checkpointer) - state_snapshot = graph.get_state(thread) + state_snapshot = graph.get_state(graph_config) ## if the next step is a tool call if state_snapshot.next == ('dangerous_tools', ): @@ -259,7 +263,7 @@ async def report_stream_state(force: bool = False): last_stream_update = now last_reported_stream_state = stream_state - async for event in graph.astream(new_input, thread, stream_mode=stream_mode): + async for event in graph.astream(new_input, graph_config, stream_mode=stream_mode): if isinstance(event, tuple): mode, payload = event else: @@ -288,7 +292,7 @@ async def report_stream_state(force: bool = False): await report_stream_state(force=True) - state_snapshot = graph.get_state(thread) + state_snapshot = graph.get_state(graph_config) actions = '' if state_snapshot.next == ('dangerous_tools', ): actions = json.dumps(last_message.tool_calls)