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) <noreply@anthropic.com>
This commit is contained in:
Wes Huber
2026-06-07 07:46:21 -07:00
committed by GitHub
parent 706ea6a7b7
commit b9a96bca1a
+2 -1
View File
@@ -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