fix: detect malformed DSML closing tags near response end

This commit is contained in:
Liang Jiaqing committed 2026-10-21 17:57:30 +08:00
1 parent e6b1bcec92
commit 7c79515cf7
1 file changed
+1 -1
+1 -1
View File
@@ -476,7 +476,7 @@ class GenericAgentHandler(BaseHandler):
return self._retry_or_exit("[ERROR] Blank response, regenerate and tooluse") return self._retry_or_exit("[ERROR] Blank response, regenerate and tooluse")
if '[!!! 流异常中断' in content[-100:] or '!!!Error:' in content[50:][-100:] or (content.endswith('</summary>') and len(content) < 100): if '[!!! 流异常中断' in content[-100:] or '!!!Error:' in content[50:][-100:] or (content.endswith('</summary>') and len(content) < 100):
return self._retry_or_exit("[ERROR] Incomplete response. Regenerate and tooluse.") return self._retry_or_exit("[ERROR] Incomplete response. Regenerate and tooluse.")
if content.rstrip().endswith('</|DSML| calls>'): if '</|DSML|' in content.rstrip()[-50:] and content.rstrip().endswith('>'):
return self._retry_or_exit("[ERROR] Tool call format invalid; no tool was called. Regenerate using proper tool calls.") return self._retry_or_exit("[ERROR] Tool call format invalid; no tool was called. Regenerate using proper tool calls.")
if 'max_tokens !!!]' in content[-100:]: if 'max_tokens !!!]' in content[-100:]:
return self._retry_or_exit("[ERROR] max_tokens limit reached. Use multi small steps to do it.") return self._retry_or_exit("[ERROR] max_tokens limit reached. Use multi small steps to do it.")