Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
serve: only a whole quoted <function=NAME> opener keeps a parameter value open (#4078)
Tsuryb72f56e02ae5
diff --git a/serve/frontend.py b/serve/frontend.pyindex 1687983fd..cb8e1cda9 100644--- a/serve/frontend.py+++ b/serve/frontend.py@@ -748,15 +748,19 @@ _LOOSE_OPEN = re.compile(r"<\s*(?:function\s*[=:]\s*|=\s*)?([A-Za-z0-9_.\-]+)\s*_LOOSE_PART = re.compile(r"<\s*(?:function[ \t]*[=:]?\s*|=\s*)?[A-Za-z0-9_.\-]*\s*$")+# a quoted call's opener in a value: `<function=NAME>` and its first parameter or close; a bare FUNC_START is text+_QUOTED_OPEN = re.compile(r"<function=[^<>\s]+>\s*(?:<parameter=|</function>)")++def param_end(text: str, final: bool = False, name: str | None = None) -> int:"""Where a parameter value in `text` ends: the first PARAM_END followed (after whitespace) by the nextPARAM_START or FUNC_END - the same text inside a value (a file that documents the call format, #210) is- part of the value. #4078: a close inside a call the value itself quotes (more FUNC_START than FUNC_END before+ part of the value. #4078: a close inside a call the value itself quotes (more _QUOTED_OPEN than FUNC_END beforeit), or one followed by the same parameter `name` again, is part of the value too. `text` starts at the value.-1: none yet; -2: a candidate whose follower has not arrived (streaming; `final` accepts it)."""at = text.find(PARAM_END)while at >= 0:- if text.count(FUNC_START, 0, at) <= text.count(FUNC_END, 0, at):+ if len(_QUOTED_OPEN.findall(text, 0, at)) <= text.count(FUNC_END, 0, at):after = text[at + len(PARAM_END):].lstrip()if after.startswith(PARAM_START):gt = after.find(">")diff --git a/serve/test_quoted_call_values.py b/serve/test_quoted_call_values.pyindex 7d5eac3ae..9eae21a02 100644--- a/serve/test_quoted_call_values.py+++ b/serve/test_quoted_call_values.py@@ -15,6 +15,8 @@ VALUES = {"quoted call at the end": f"example transcript:\n{QUOTED}","heredoc": f"python3 - <<'PY'\nprint('''{QUOTED}''')\nPY","repeated parameter": f"head part\n{PARAM_END}\n{PARAM_START}content>\ntail part",+ "unclosed opener in prose": f"A call starts with `{FUNC_START}NAME>` and its parameters follow.",+ "unclosed opener in code": f'opener = "{FUNC_START}"\n',}