From 9f33c966c91c74a338830908bcef38da215372ef Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Thu, 29 Oct 2026 20:51:10 +0100 Subject: [PATCH] feat: raise the default tool-call iteration limit per response to 1024 (#33384) With native function calling, each model turn that calls tools counts as one iteration, and a single response was stopped with "Tool-call limit reached (256 iterations)." after 256 of them. The CHAT_RESPONSE_MAX_TOOL_CALL_ITERATIONS environment variable now defaults to 1024, also when it is set empty or to something that is not a number, and the error shows the new number. A model stuck calling tools in a loop now runs up to 1024 iterations before it is stopped; setting the variable to 256 keeps the old limit, and -1 still means no limit. --- backend/open_webui/env.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/open_webui/env.py b/backend/open_webui/env.py index 0e2797c3af..14e882ca42 100644 --- a/backend/open_webui/env.py +++ b/backend/open_webui/env.py @@ -1128,16 +1128,16 @@ else: # The old CHAT_RESPONSE_MAX_TOOL_CALL_RETRIES name is accepted as a fallback. CHAT_RESPONSE_MAX_TOOL_CALL_ITERATIONS = os.getenv( 'CHAT_RESPONSE_MAX_TOOL_CALL_ITERATIONS', - os.getenv('CHAT_RESPONSE_MAX_TOOL_CALL_RETRIES', '256'), + os.getenv('CHAT_RESPONSE_MAX_TOOL_CALL_RETRIES', '1024'), ) if CHAT_RESPONSE_MAX_TOOL_CALL_ITERATIONS == '': - CHAT_RESPONSE_MAX_TOOL_CALL_ITERATIONS = 256 + CHAT_RESPONSE_MAX_TOOL_CALL_ITERATIONS = 1024 else: try: CHAT_RESPONSE_MAX_TOOL_CALL_ITERATIONS = int(CHAT_RESPONSE_MAX_TOOL_CALL_ITERATIONS) except Exception: - CHAT_RESPONSE_MAX_TOOL_CALL_ITERATIONS = 256 + CHAT_RESPONSE_MAX_TOOL_CALL_ITERATIONS = 1024 # -1 means unlimited (no cap). if CHAT_RESPONSE_MAX_TOOL_CALL_ITERATIONS == -1: