fix(reasoning): guard rfind in ernie45 streaming </response> branch (#46255)
Signed-off-by: Chenglun Hu <chenglunhu@gmail.com> Co-authored-by: Flora Feng <4florafeng@gmail.com>
hcl committed
Jul 1, 2026 at 09:01 UTC
9294dd27eb9caa4270a87dbbb61f4d0449a18407
1 file changed
+2
-1
vllm/reasoning/ernie45_reasoning_parser.py
+2
-1
@@ -114,7 +114,8 @@ class Ernie45ReasoningParser(BaseThinkingReasoningParser):
114
content = content[:response_end_idx]
115
elif self.response_end_token_id in delta_token_ids:
116
response_end_idx = content.rfind(self.response_end_token)
117
- content = content[:response_end_idx]
117
+ if response_end_idx != -1:
118
+ content = content[:response_end_idx]
119
# remove \n after </think> or </response>
120
if previous_token_ids[-1] in self.parser_token_ids and (
121
len(delta_token_ids) > 0 and delta_token_ids[0] == self.newline_token_id