From a584ffe92dfe76669a483ce77483c1c665b52a7f Mon Sep 17 00:00:00 2001 From: chengyongru Date: Wed, 24 Jun 2026 15:40:53 +0800 Subject: [PATCH] refactor: trim thinking tag helper setup maintainer edit: remove unused self-closing tag derivation and duplicate reasoning partial cleanup after ponytail review. --- nanobot/utils/helpers.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/nanobot/utils/helpers.py b/nanobot/utils/helpers.py index 32824aaf..a0577dca 100644 --- a/nanobot/utils/helpers.py +++ b/nanobot/utils/helpers.py @@ -70,12 +70,8 @@ def _tag_regex(tags: tuple[str, ...]) -> str: _THINKING_TAGS = ("think", "thinking", "thought") -_INLINE_SELF_CLOSING_PRESERVED_TAGS = frozenset({"think", "thought"}) -_INLINE_SELF_CLOSING_THINKING_TAGS = tuple( - tag for tag in _THINKING_TAGS if tag not in _INLINE_SELF_CLOSING_PRESERVED_TAGS -) _THINKING_TAG = _tag_regex(_THINKING_TAGS) -_INLINE_SELF_CLOSING_THINKING_TAG = _tag_regex(_INLINE_SELF_CLOSING_THINKING_TAGS) +_INLINE_SELF_CLOSING_THINKING_TAG = r"(?:thinking)" _THINKING_TAG_PREFIX = "|".join( sorted( {re.escape(tag[:i]) for tag in _THINKING_TAGS for i in range(1, len(tag) + 1)}, @@ -145,7 +141,6 @@ def strip_reasoning_tags(text: object) -> str: """Remove wrapper tags from text that is already known to be reasoning.""" if not isinstance(text, str): return "" - text = re.sub(rf"^\s*(?:{_PARTIAL_THINKING_TAG})$", "", text) text = re.sub(rf"^\s*<{_THINKING_TAG}/>\s*", "", text) text = re.sub(rf"\s*<{_THINKING_TAG}/>\s*$", "", text) text = re.sub(rf"^\s*<{_THINKING_TAG}>\s*", "", text)