Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

studio: stop nudging a turn that asks the user for a missing detail (#8946)

Maheswar Kumar657aea945b3b
diff --git a/studio/backend/core/inference/tool_call_parser.py b/studio/backend/core/inference/tool_call_parser.py
index c8da02f5008..cf2f2d5b250 100644
--- a/studio/backend/core/inference/tool_call_parser.py
+++ b/studio/backend/core/inference/tool_call_parser.py
@@ -177,9 +177,12 @@ _ACTION_VERB = (
# turns, "I'll do my best to help" and "allow me to assist" close a clarification
# request and never precede a tool call. "help you" keeps its plan reading when an
# action follows it ("I'll help you search the web").
+# name no work of their own, so they only ever sign off a question to the user (#8907)
+_SIGN_OFF = r"(?:dig\s+in|help\s+analy[sz]e)\b(?=[^\w]*\Z)" # \Z not $: a later line is still work
_HELP_OFFER = (
r"(?:do(?:ing)?\s+my\s+best|try\s+my\s+best|be\s+(?:able|happy|glad)\s+to\b"
- r"|assist\b|help\s+you\b(?!\s+" + _ACTION_VERB + r")|give\s+you\s+accurate\b)"
+ r"|assist\b|help\s+you\b(?!\s+" + _ACTION_VERB + r")|give\s+you\s+accurate\b"
+ r"|" + _SIGN_OFF + r")"
)
# Forward-looking intent: the model says what it *will* do, not a final answer.
INTENT_SIGNAL = re.compile(
@@ -189,7 +192,9 @@ INTENT_SIGNAL = re.compile(
r"(?!\s+(?:not|never)\b)(?!\s+" + _HELP_OFFER + r")"
r"|"
# "let me know" hands control back rather than announcing an action.
- r"\b(?:let me|allow me)\b(?!\s+(?:not|never|know)\b)(?!\s+to\s+" + _HELP_OFFER + r")"
+ r"\b(?:let me|allow me)\b(?!\s+(?:not|never|know)\b)"
+ # bare "assist" still names work here ("let me assist by searching"), so only the sign-offs skip the "to"
+ r"(?!\s+" + _SIGN_OFF + r")(?!\s+to\s+" + _HELP_OFFER + r")"
r"|"
# Step/plan framing. "first" must open a sentence and be followed by a plan
# (pronoun, "my/our plan", or an action verb); otherwise it is prose ("The
diff --git a/studio/backend/tests/data/refactor_guard/ast_inventory.json b/studio/backend/tests/data/refactor_guard/ast_inventory.json
index 0534b947bf9..fd532dd031a 100644
--- a/studio/backend/tests/data/refactor_guard/ast_inventory.json
+++ b/studio/backend/tests/data/refactor_guard/ast_inventory.json
@@ -724,7 +724,7 @@
},
"core.inference.tool_call_parser": {
"compiled": {
- "INTENT_SIGNAL": "\"(?im)(\\\\b(i['\\\\u2019](ll|m going to|m gonna)|i am (going to|gonna)|i will|i shall)\\\\b(?!\\\\s+(?:not|never)\\\\b)(?!\\\\s+(?:do(?:ing)?\\\\s+my\\\\s+best|try\\\\s+my\\\\s+best|be\\\\s+(?:able|happy|glad)\\\\s+to\\\\b|assist\\\\b|help\\\\s+you\\\\b(?!\\\\s+(?:search|check|look|find|fetch|get|call|use|run|query|invoke|analy[sz]e|review|inspect|read|gather|examine|retrieve|browse|consult|verify|confirm|compute|calculate|determine|identify|render))|give\\\\s+you\\\\s+accurate\\\\b))|\\\\b(?:let me|allow me)\\\\b(?!\\\\s+(?:not|never|know)\\\\b)(?!\\\\s+to\\\\s+(?:do(?:ing)?\\\\s+my\\\\s+best|try\\\\s+my\\\\s+best|be\\\\s+(?:able|happy|glad)\\\\s+to\\\\b|assist\\\\b|help\\\\s+you\\\\b(?!\\\\s+(?:search|check|look|find|fetch|get|call|use|run|query|invoke|analy[sz]e|review|inspect|read|gather|examine|retrieve|browse|consult|verify|confirm|compute|calculate|determine|identify|render))|give\\\\s+you\\\\s+accurate\\\\b))|(?:^|[.!?]\\\\s+)\\\\s*(?:the\\\\s+)?first\\\\s+step\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+(?:my|our)\\\\s+(?:plan|approach|step)\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+(?:i|we|let['’]?s|let us)\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+(?:search|check|look|find|fetch|get|call|use|run|query|invoke|analy[sz]e|review|inspect|read|gather|examine|retrieve|browse|consult|verify|confirm|compute|calculate|determine|identify|render)\\\\b|\\\\b(?:step \\\\d+:?|here['\\\\u2019]?s (?:my |the |a )?(?:plan|approach))|\\\\b(?:now i|next i)\\\\b)\" flags=42",
+ "INTENT_SIGNAL": "\"(?im)(\\\\b(i['\\\\u2019](ll|m going to|m gonna)|i am (going to|gonna)|i will|i shall)\\\\b(?!\\\\s+(?:not|never)\\\\b)(?!\\\\s+(?:do(?:ing)?\\\\s+my\\\\s+best|try\\\\s+my\\\\s+best|be\\\\s+(?:able|happy|glad)\\\\s+to\\\\b|assist\\\\b|help\\\\s+you\\\\b(?!\\\\s+(?:search|check|look|find|fetch|get|call|use|run|query|invoke|analy[sz]e|review|inspect|read|gather|examine|retrieve|browse|consult|verify|confirm|compute|calculate|determine|identify|render))|give\\\\s+you\\\\s+accurate\\\\b|(?:dig\\\\s+in|help\\\\s+analy[sz]e)\\\\b(?=[^\\\\w]*\\\\Z)))|\\\\b(?:let me|allow me)\\\\b(?!\\\\s+(?:not|never|know)\\\\b)(?!\\\\s+(?:dig\\\\s+in|help\\\\s+analy[sz]e)\\\\b(?=[^\\\\w]*\\\\Z))(?!\\\\s+to\\\\s+(?:do(?:ing)?\\\\s+my\\\\s+best|try\\\\s+my\\\\s+best|be\\\\s+(?:able|happy|glad)\\\\s+to\\\\b|assist\\\\b|help\\\\s+you\\\\b(?!\\\\s+(?:search|check|look|find|fetch|get|call|use|run|query|invoke|analy[sz]e|review|inspect|read|gather|examine|retrieve|browse|consult|verify|confirm|compute|calculate|determine|identify|render))|give\\\\s+you\\\\s+accurate\\\\b|(?:dig\\\\s+in|help\\\\s+analy[sz]e)\\\\b(?=[^\\\\w]*\\\\Z)))|(?:^|[.!?]\\\\s+)\\\\s*(?:the\\\\s+)?first\\\\s+step\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+(?:my|our)\\\\s+(?:plan|approach|step)\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+(?:i|we|let['’]?s|let us)\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+(?:search|check|look|find|fetch|get|call|use|run|query|invoke|analy[sz]e|review|inspect|read|gather|examine|retrieve|browse|consult|verify|confirm|compute|calculate|determine|identify|render)\\\\b|\\\\b(?:step \\\\d+:?|here['\\\\u2019]?s (?:my |the |a )?(?:plan|approach))|\\\\b(?:now i|next i)\\\\b)\" flags=42",
"_ATTR_FUNC_OPEN_RE": "'<function\\\\s+name=\"' flags=32",
"_BARE_JSON_NAME_RE": "'\"name\"\\\\s*:\\\\s*\"([^\"]+)\"' flags=32",
"_DEEPSEEK_BEGIN_RE": "'<|(?:tool▁calls▁begin|tool_calls_begin|tool calls begin|tool\\\\\\\\_calls\\\\\\\\_begin|tool▁calls)|>' flags=32",
@@ -783,7 +783,7 @@
"_TOOL_CLOSED_PATS[7]": "'<\\\\|tool_call_begin\\\\|>.*?<\\\\|tool_call_end\\\\|>' flags=48"
},
"regexes": {
- "re.compile(\"(?im)(\\\\b(i['\\\\u2019](ll|m going to|m gonna)|i am (going to|gonna)|i will|i shall)\\\\b(?!\\\\s+(?:not|never)\\\\b)(?!\\\\s+\" + _HELP_OFFER + ')|\\\\b(?:let me|allow me)\\\\b(?!\\\\s+(?:not|never|know)\\\\b)(?!\\\\s+to\\\\s+' + _HELP_OFFER + \")|(?:^|[.!?]\\\\s+)\\\\s*(?:the\\\\s+)?first\\\\s+step\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+(?:my|our)\\\\s+(?:plan|approach|step)\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+(?:i|we|let['’]?s|let us)\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+\" + _ACTION_VERB + \"\\\\b|\\\\b(?:step \\\\d+:?|here['\\\\u2019]?s (?:my |the |a )?(?:plan|approach))|\\\\b(?:now i|next i)\\\\b)\")": 1,
+ "re.compile(\"(?im)(\\\\b(i['\\\\u2019](ll|m going to|m gonna)|i am (going to|gonna)|i will|i shall)\\\\b(?!\\\\s+(?:not|never)\\\\b)(?!\\\\s+\" + _HELP_OFFER + ')|\\\\b(?:let me|allow me)\\\\b(?!\\\\s+(?:not|never|know)\\\\b)(?!\\\\s+' + _SIGN_OFF + ')(?!\\\\s+to\\\\s+' + _HELP_OFFER + \")|(?:^|[.!?]\\\\s+)\\\\s*(?:the\\\\s+)?first\\\\s+step\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+(?:my|our)\\\\s+(?:plan|approach|step)\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+(?:i|we|let['’]?s|let us)\\\\b|(?:^|[.!?]\\\\s+)\\\\s*first\\\\s*[,:–—-]?\\\\s+\" + _ACTION_VERB + \"\\\\b|\\\\b(?:step \\\\d+:?|here['\\\\u2019]?s (?:my |the |a )?(?:plan|approach))|\\\\b(?:now i|next i)\\\\b)\")": 1,
"re.compile('\"name\"\\\\s*:\\\\s*\"([^\"]+)\"')": 1,
"re.compile('(?<!\\\\w)call\\\\s*(?::\\\\s*[\\\\w\\\\.\\\\-]*)?$')": 1,
"re.compile('(?<!\\\\w)call\\\\s*:\\\\s*([\\\\w\\\\.\\\\-]+)\\\\s*\\\\{')": 1,
@@ -1094,6 +1094,9 @@
"_SENTINEL_MAX_LEN": {
"kind": "assign"
},
+ "_SIGN_OFF": {
+ "kind": "assign"
+ },
"_STRIP_SENTINELS": {
"kind": "assign"
},
diff --git a/studio/backend/tests/data/refactor_guard/runtime_inventory.json b/studio/backend/tests/data/refactor_guard/runtime_inventory.json
index f5d481f6906..0348a9096d0 100644
--- a/studio/backend/tests/data/refactor_guard/runtime_inventory.json
+++ b/studio/backend/tests/data/refactor_guard/runtime_inventory.json
@@ -76,6 +76,7 @@
"_REPEAT_LEAD_PUNCT",
"_REPEAT_TRAIL_PUNCT",
"_SENTINEL_MAX_LEN",
+ "_SIGN_OFF",
"_STRIP_SENTINELS",
"_TC_END_TAG_RE",
"_TC_FUNC_CLOSE_RE",
diff --git a/studio/backend/tests/test_llama_cpp_tool_loop.py b/studio/backend/tests/test_llama_cpp_tool_loop.py
index 713659590cf..0698d1cea94 100644
--- a/studio/backend/tests/test_llama_cpp_tool_loop.py
+++ b/studio/backend/tests/test_llama_cpp_tool_loop.py
@@ -3025,6 +3025,41 @@ def test_direct_answer_never_shows_the_nudge_status(monkeypatch):
assert NUDGE_TOOL_CALLS_STATUS not in _status_texts(events)
+def test_clarification_request_is_not_nudged(monkeypatch):
+ """#8907: the model asked what the user wants, so there is nothing to act on.
+
+ The turn signs off with "I'll dig in", which ``INTENT_SIGNAL`` used to read as a
+ plan. Nudging it regenerated the turn and showed two near-identical questions.
+ """
+
+ clarification = (
+ '"balls" is pretty broad, so what would you like to know or do?\n\n'
+ "- Sports: rules of a game\n"
+ "- Physics: projectile motion, volume of a sphere\n\n"
+ "Let me know what you're after and I'll dig in."
+ )
+ payloads: list[dict] = []
+ backend = _make_backend(
+ monkeypatch,
+ [[_sse({"content": clarification}), _done()]],
+ payloads,
+ )
+
+ events = list(
+ backend.generate_chat_completion_with_tools(
+ messages = [{"role": "user", "content": "Balls"}],
+ tools = [_WEB_SEARCH_TOOL],
+ max_tool_iterations = 2,
+ )
+ )
+
+ assert NUDGE_TOOL_CALLS_STATUS not in _status_texts(events)
+ # one payload: a second would be the wasted re-prompted generation.
+ assert len(payloads) == 1
+ content_texts = [event.get("text", "") for event in events if event.get("type") == "content"]
+ assert content_texts and content_texts[-1] == clarification
+
+
def test_nudge_status_absent_when_nudging_is_disabled(monkeypatch):
payloads: list[dict] = []
backend = _make_backend(monkeypatch, _nudge_then_search_streams(), payloads)
diff --git a/studio/backend/tests/test_plan_classifier_accuracy.py b/studio/backend/tests/test_plan_classifier_accuracy.py
index 9144fb92e32..d5bec895846 100644
--- a/studio/backend/tests/test_plan_classifier_accuracy.py
+++ b/studio/backend/tests/test_plan_classifier_accuracy.py
@@ -24,11 +24,12 @@ retry's text can then be discarded, which costs the user a visible answer.
Measured when this landed, over the 300 turns:
tree nudged retry discarded
- origin/main (pre-PR) 36 (12.0%) 60 (20.2%)
- this PR 5 ( 1.7%) 1 ( 0.3%)
+ before the classifier landed 36 (12.0%) 60 (20.2%)
+ classifier as first landed 5 ( 1.7%) 1 ( 0.3%)
+ with the #8907 sign-off fix 4 ( 1.3%) 0 ( 0.0%)
The budgets below sit above the measured counts so that innocuous wording changes
-do not fail the build, and far below the pre-PR counts so a real regression does.
+do not fail the build, and far below the first row so a real regression does.
A failure prints the offending turns: fix the pattern, or if the turn really is a
stall, correct its label here.
"""
@@ -41,9 +42,9 @@ from core.inference.tool_call_parser import is_short_intent_without_action
DATA = Path(__file__).parent / "data" / "plan_vs_answer.jsonl"
-# Measured 5 of 300; pre-PR was 36.
+# above the measured count in the table above, so wording changes alone do not fail the build
NUDGE_BUDGET = 9
-# Measured 1 of 300; pre-PR was 60. Tighter, because this one destroys output.
+# tighter than the nudge budget, because a discarded retry destroys output
DISCARD_BUDGET = 4
diff --git a/studio/backend/tests/test_safetensors_tool_loop.py b/studio/backend/tests/test_safetensors_tool_loop.py
index 9c51554854c..14a8d89cc5c 100644
--- a/studio/backend/tests/test_safetensors_tool_loop.py
+++ b/studio/backend/tests/test_safetensors_tool_loop.py
@@ -3661,6 +3661,16 @@ class TestGGUFSafetensorsHealingParity:
"Now I need to call web_search",
# The "let me know" exemption is scoped to "let me", not all direct intent.
"I will know the answer after I search the web",
+ # the sign-offs only count when nothing follows them; named work keeps the plan reading.
+ "I'll dig into the source now and report back.",
+ "I'll dig in and search the web for the latest numbers.",
+ "I'll dig in, then run the numbers.",
+ "I'll dig in. Starting with a web search.",
+ "I'll dig in.\nStarting with a web search.",
+ "I'll help analyze the sales data now.",
+ # "let me assist" names work without a "to", so only the sign-offs skip that gate.
+ "Let me assist by searching the web now.",
+ "Let me assist with checking the documentation.",
):
assert shared_re.search(phrase), f"missed {phrase!r}"
assert shared_fn(phrase), f"helper missed {phrase!r}"
@@ -3678,6 +3688,10 @@ class TestGGUFSafetensorsHealingParity:
"I'll never call that tool.",
# Hands control back rather than announcing an action.
"Let me know if you need anything else.",
+ # #8907: a question to the user, signed off with an action that names no work.
+ "Let me know what you're after and I'll dig in.",
+ 'Could you clarify what "it" means? Let me know and I\'ll help analyze!',
+ "Tell me what you are after and let me dig in.",
"First, the answer is 42",
"First, the result is 3.",
"First, it is 42",