From b9a96bca1aa60206bd3895988dca1d4113b9a285 Mon Sep 17 00:00:00 2001 From: Wes Huber Date: Sun, 7 Jun 2026 07:46:21 -0700 Subject: [PATCH] fix(research): avoid double split() call and potential IndexError (#2229) cat.split()[0] was called in the condition and again in the body, wasting a second split. More importantly, if cat were ever whitespace-only, split() returns [] and [0] raises IndexError. Assign to a local variable and guard with a truthiness check. Co-authored-by: Claude Opus 4.6 (1M context) --- src/deep_research.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/deep_research.py b/src/deep_research.py index 375d8d8ab..2045d1c1f 100644 --- a/src/deep_research.py +++ b/src/deep_research.py @@ -439,7 +439,8 @@ class DeepResearcher: ) cat = (result or "").strip().lower() # Clean one-word answer first. - first = cat.split()[0].strip(".,\"'*:") if cat.split() else "" + parts = cat.split() + first = parts[0].strip(".,\"'*:") if parts else "" if first in CATEGORY_PROMPTS: return first # Weak local models often wrap the label in preamble ("the category