From 4f5ffb89095962632da2861e05c87f150d323b39 Mon Sep 17 00:00:00 2001 From: teknium1 Date: Tue, 3 Mar 2026 03:42:44 -0800 Subject: [PATCH] fix: NoneType not iterable error when summarizing at max iterations In _handle_max_iterations, the codex_responses path set tools=None to prevent tool calls during summarization. However, the OpenAI SDK's _make_tools() treats None as a valid value (not its Omit sentinel) and tries to iterate over it, causing TypeError: 'NoneType' object is not iterable. Fix: use codex_kwargs.pop('tools', None) to remove the key entirely, so the SDK never receives it and uses its default omit behavior. Fixes #300 --- run_agent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run_agent.py b/run_agent.py index 4c60b4bd8..9c49756ba 100644 --- a/run_agent.py +++ b/run_agent.py @@ -2667,7 +2667,7 @@ class AIAgent: if self.api_mode == "codex_responses": codex_kwargs = self._build_api_kwargs(api_messages) - codex_kwargs["tools"] = None + codex_kwargs.pop("tools", None) summary_response = self._run_codex_stream(codex_kwargs) assistant_message, _ = self._normalize_codex_response(summary_response) final_response = (assistant_message.content or "").strip() if assistant_message else "" @@ -2713,7 +2713,7 @@ class AIAgent: # Retry summary generation if self.api_mode == "codex_responses": codex_kwargs = self._build_api_kwargs(api_messages) - codex_kwargs["tools"] = None + codex_kwargs.pop("tools", None) retry_response = self._run_codex_stream(codex_kwargs) retry_msg, _ = self._normalize_codex_response(retry_response) final_response = (retry_msg.content or "").strip() if retry_msg else ""