fix: handle yuyar typo variant of yuyay-response tags

Models occasionally misspell yuyay as yuyar since it's a made-up word.
Use [yr] character class in all regexes and partial tag prefixes.
This commit is contained in:
Joey Yakimowich-Payne 2026-03-14 09:16:47 -06:00
commit 5580bc87cc
2 changed files with 11 additions and 4 deletions

View file

@ -72,13 +72,20 @@ import re as _re
# streaming responses and executes the contained ops in real-time.
# ---------------------------------------------------------------------------
_TAG_OPEN_RE = _re.compile(r"<(memory_cleanup|yuyay-response)")
_TAG_CLOSE_RE = _re.compile(r"</(memory_cleanup|yuyay-response)>")
_TAG_OPEN_RE = _re.compile(r"<(memory_cleanup|yuya[yr]-response)")
_TAG_CLOSE_RE = _re.compile(r"</(memory_cleanup|yuya[yr]-response)>")
# Matches a trailing '<' optionally followed by a prefix of a known tag name
# or '</'. Used to detect partial tag openers that arrive split across SSE
# text deltas (e.g. "<y", "<mem", "</memory_cl").
_KNOWN_TAG_PREFIXES = ("memory_cleanup", "yuyay-response", "/memory_cleanup", "/yuyay-response")
_KNOWN_TAG_PREFIXES = (
"memory_cleanup",
"yuyay-response",
"yuyar-response",
"/memory_cleanup",
"/yuyay-response",
"/yuyar-response",
)
def _has_partial_tag(buf: str) -> bool:

View file

@ -166,7 +166,7 @@ def parse_cleanup_tags(text: str) -> CleanupOps:
# Match <yuyay-response>...</yuyay-response> blocks
_YUYAY_RESPONSE_PATTERN = re.compile(
r"<yuyay-response>\s*(.*?)\s*</yuyay-response>",
r"<yuya[yr]-response>\s*(.*?)\s*</yuya[yr]-response>",
re.DOTALL,
)