Skip to content

armgit / strix

Public Imported from GitHub
0

Open-source AI penetration testing tool to find and fix your app’s vulnerabilities.

fix: Address code review feedback on tool format normalization

0xallamb9dcf7f63d68
diff --git a/strix/llm/llm.py b/strix/llm/llm.py
index 507e8c82..d941361b 100644
--- a/strix/llm/llm.py
+++ b/strix/llm/llm.py
@@ -145,11 +145,9 @@ class LLM:
if delta:
accumulated += delta
if "</function>" in accumulated or "</invoke>" in accumulated:
- for end_tag in ("</function>", "</invoke>"):
- pos = accumulated.find(end_tag)
- if pos != -1:
- accumulated = accumulated[: pos + len(end_tag)]
- break
+ end_tag = "</function>" if "</function>" in accumulated else "</invoke>"
+ pos = accumulated.find(end_tag)
+ accumulated = accumulated[: pos + len(end_tag)]
yield LLMResponse(content=accumulated)
done_streaming = 1
continue
diff --git a/strix/llm/utils.py b/strix/llm/utils.py
index b8666617..1ba6a5f6 100644
--- a/strix/llm/utils.py
+++ b/strix/llm/utils.py
@@ -3,8 +3,8 @@ import re
from typing import Any
-_INVOKE_OPEN = re.compile(r'<invoke\s+name=["\']([^"\']+)["\']\s*>')
-_PARAM_NAME_ATTR = re.compile(r'<parameter\s+name=["\']([^"\']+)["\']\s*>')
+_INVOKE_OPEN = re.compile(r'<invoke\s+name=["\']([^"\']+)["\']>')
+_PARAM_NAME_ATTR = re.compile(r'<parameter\s+name=["\']([^"\']+)["\']>')
_FUNCTION_CALLS_TAG = re.compile(r"</?function_calls>")
_QUOTED_FUNCTION = re.compile(r"""<function\s*=\s*['"]([^"']+)['"]\s*>""")
_QUOTED_PARAMETER = re.compile(r"""<parameter\s*=\s*['"]([^"']+)['"]\s*>""")