From c2aa235328223d931ca8d61b803d8c5a6b4e96eb Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Mon, 25 May 2026 15:16:54 -0700 Subject: [PATCH] fix(agent): log outer-loop exceptions at ERROR with traceback (#32264) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The outer 'except Exception' guard in run_conversation() captures exceptions raised inside the agent loop (during streaming, tool dispatch, message construction, etc.) and prints a one-line summary to the screen. The traceback was only logged at DEBUG, so it never landed in errors.log (WARNING+) and was lost. For intermittent failures — the most important kind to debug — users saw 'Error during OpenAI-compatible API call #N: ' on screen with no way to recover the call site. Switching to logger.exception() emits the full traceback at ERROR so it goes to both agent.log and errors.log automatically. This is a pure logging change; control flow is unchanged. --- agent/conversation_loop.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/agent/conversation_loop.py b/agent/conversation_loop.py index cab284986f5..abcb342d04f 100644 --- a/agent/conversation_loop.py +++ b/agent/conversation_loop.py @@ -3945,8 +3945,14 @@ def run_conversation( print(f"❌ {error_msg}") except (OSError, ValueError): logger.error(error_msg) - - logger.debug("Outer loop error in API call #%d", api_call_count, exc_info=True) + + # Emit the full traceback at ERROR level so it lands in both + # agent.log AND errors.log. Previously this was logged at DEBUG, + # which meant intermittent outer-loop failures were unreproducible + # — users would see a one-line summary on screen with no way to + # recover the call site. logger.exception() includes the + # traceback automatically and emits at ERROR. + logger.exception("Outer loop error in API call #%d", api_call_count) # If an assistant message with tool_calls was already appended, # the API expects a role="tool" result for every tool_call_id.