From a77ca9295e96af9f0da522b1bd3afe1965ef21ee Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Sat, 16 May 2026 23:20:27 -0700 Subject: [PATCH] perf(run_agent): accumulate length-continuation prefix via list+join Original commit 4f8aaf104 by InB4DevOps targeted run_conversation() in the pre-refactor run_agent.py. Re-applied to the extracted location in agent/conversation_loop.py. Co-authored-by: InB4DevOps --- agent/conversation_loop.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/agent/conversation_loop.py b/agent/conversation_loop.py index c95f1b63385..6fd9a6aec1d 100644 --- a/agent/conversation_loop.py +++ b/agent/conversation_loop.py @@ -464,7 +464,7 @@ def run_conversation( codex_ack_continuations = 0 length_continue_retries = 0 truncated_tool_call_retries = 0 - truncated_response_prefix = "" + truncated_response_parts: List[str] = [] compression_attempts = 0 _turn_exit_reason = "unknown" # Diagnostic: why the loop ended @@ -1357,7 +1357,7 @@ def run_conversation( interim_msg = agent._build_assistant_message(assistant_message, finish_reason) messages.append(interim_msg) if assistant_message.content: - truncated_response_prefix += assistant_message.content + truncated_response_parts.append(assistant_message.content) if length_continue_retries < 3: agent._vprint( @@ -1378,7 +1378,7 @@ def run_conversation( restart_with_length_continuation = True break - partial_response = agent._strip_think_blocks(truncated_response_prefix).strip() + partial_response = agent._strip_think_blocks("".join(truncated_response_parts)).strip() agent._cleanup_task_resources(effective_task_id) agent._persist_session(messages, conversation_history) return { @@ -3582,9 +3582,9 @@ def run_conversation( codex_ack_continuations = 0 - if truncated_response_prefix: - final_response = truncated_response_prefix + final_response - truncated_response_prefix = "" + if truncated_response_parts: + final_response = "".join(truncated_response_parts) + final_response + truncated_response_parts = [] length_continue_retries = 0 final_response = agent._strip_think_blocks(final_response).strip()