From 24282dceb1d35d5bfd42444ec0c16043b7849160 Mon Sep 17 00:00:00 2001 From: teknium1 Date: Tue, 17 Mar 2026 04:05:20 -0700 Subject: [PATCH] fix(core): reset length_continue_retries after successful continuation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit length_continue_retries and truncated_response_prefix were initialized once before the outer loop and never reset after a successful continuation. If a conversation hit length truncation once (counter=1), succeeded on continuation, did more tool calls, then hit length again, the counter started at 1 instead of 0 — reducing available retries from 3 to 2. The stale truncated_response_prefix would also leak into the next response. Reset both after the prefix is consumed on a successful final response. --- run_agent.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run_agent.py b/run_agent.py index f71206c5..51184111 100644 --- a/run_agent.py +++ b/run_agent.py @@ -6169,6 +6169,8 @@ class AIAgent: if truncated_response_prefix: final_response = truncated_response_prefix + final_response + truncated_response_prefix = "" + length_continue_retries = 0 # Strip blocks from user-facing response (keep raw in messages for trajectory) final_response = self._strip_think_blocks(final_response).strip()