mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-15 17:25:26 -04:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user