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.
This commit is contained in:
Classic298 2026-10-29 20:51:10 +01:00 • committed by GitHub
parent 8650cd2dd5
commit 9f33c966c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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: