From 8118327affc537e9f10833f551560e943f331891 Mon Sep 17 00:00:00 2001 From: songji-tian <317775411+songji-tian@users.noreply.github.com> Date: Thu, 15 Oct 2026 19:19:29 -0700 Subject: [PATCH] fix: retry whenever a DSML residual leaks into content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The server-side DSML->tool_calls parser sometimes leaves an untranslated tail in `content` and returns no `tool_calls`, e.g. ``, `` or a leaked ``. The turn then ends as a plain text reply and the agent silently stalls - no tool runs, no error. The existing guard only matches ``, a form real leaks almost never end with (0/14 in sampled transcripts). Match any trailing closed tag while still requiring the DSML marker in the last 200 chars: 14/14 caught, 0 false positives across 1960 historical responses. Retry recovers the turn (19/19 leaked turns returned proper tool_calls next try). Co-Authored-By: GenericAgent --- ga.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ga.py b/ga.py index 68ff37a5c..509b03379 100644 --- a/ga.py +++ b/ga.py @@ -485,7 +485,7 @@ def do_no_tool(self, args, response): return self._retry_or_exit("[ERROR] Blank response, regenerate and tooluse") if '[!!! 流异常中断' in content[-100:] or '!!!Error:' in content[50:][-100:] or (content.endswith('') and len(content) < 100): return self._retry_or_exit("[ERROR] Incomplete response. Regenerate and tooluse.") - if content.rstrip().endswith(''): + if 'DSML' in content[-200:] and re.search(r']*>\s*$', content.rstrip()): 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:]: return self._retry_or_exit("[ERROR] max_tokens limit reached. Use multi small steps to do it.")