diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py
index b82c262485..fdd24daf40 100644
--- a/studio/backend/core/inference/llama_cpp.py
+++ b/studio/backend/core/inference/llama_cpp.py
@@ -72,7 +72,8 @@ _TOOL_ACTION_VERBS = (
r"(?:web|internet|online(?: sources?)?)|"
r"fetch (?:the |a |an )?"
rf"{_TOOL_LOOKUP_TARGET}|"
- r"(?:research|investigate|find|check|verify) (?:for )?(?:the |a |an )?"
+ r"(?:research|investigate|find|check|verify|compare|review) "
+ r"(?:for )?(?:the |a |an )?"
rf"{_TOOL_LOOKUP_TARGET}|"
r"(?:use|invoke|call) (?:the )?(?:python|search) tool|"
r"use python(?: tool)? to|"
@@ -228,6 +229,24 @@ def _has_unclosed_code_fence(text: str) -> bool:
return active_char is not None
+def _has_unclosed_markup_block(text: str) -> bool:
+ """True if ``text`` opens an /` for the artifact branch. This helper exists to disqualify
+ the numbered-list fallback when partial markup is present: a list
+ inside an unfinished `...` body must not look like a final
+ answer.
+ """
+ return bool(
+ re.search(r"", text, re.IGNORECASE)
+ ) or bool(
+ re.search(r"