Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(brain): stop three guards from blocking on everyday German words

Haraldca44a00fe425
diff --git a/jarvis/brain/tool_use_loop.py b/jarvis/brain/tool_use_loop.py
index feea4bc0f0..63969ae984 100644
--- a/jarvis/brain/tool_use_loop.py
+++ b/jarvis/brain/tool_use_loop.py
@@ -28,6 +28,7 @@ from jarvis.brain.cu_gate import (
from jarvis.brain.spawn_gate import (
SPAWN_VEHICLE_TOOL_NAMES,
llm_spawn_allowed,
+ names_spawn_vehicle,
spawn_blocked_feedback,
)
from jarvis.core.protocols import Brain, BrainMessage, BrainRequest, ImageBlock, Tool
@@ -132,16 +133,57 @@ _RESEARCH_KEYWORDS = re.compile(
re.IGNORECASE,
)
-_META_DEBUG_KEYWORDS = re.compile(
+# Meta/debug conversation: the user is talking ABOUT the assistant's own
+# machinery (its provider, its transcript, the phrase it just spoke) instead of
+# giving it a task. Two tiers on purpose. The earlier single tier listed bare
+# everyday words — "fehler", "log", "bug", "provider", "brain", "phrase" — so a # i18n-allow
+# perfectly ordinary work turn ("Zeig mir den Fehler im Log und starte den # i18n-allow
+# Dienst neu") was classified as meta-conversation and answered with a canned
+# question instead of being carried out.
+#
+# STRONG markers name assistant machinery with no everyday reading; they stand
+# on their own and keep the guard's original case ("Warum hat der
+# Provider-Fallback gegriffen?") intact.
+_META_DEBUG_STRONG_RE = re.compile(
r"\b("
- r"api\s*key|provider|brain|text[-\s]*to[-\s]*speech|tts|"
- r"transkript|transcript|log|bug|debug|fehler|fallback|" # i18n-allow: German input-matching data (meta/debug-intent classifier)
- r"standardantwort|standardphrase|phrase|jarvis\s+sagt|"
- r"verstehst\s+du\s+was\s+ich\s+meine"
+ r"api\s*key|"
+ r"provider[-\s]*fallback|fallback[-\s]*provider|"
+ r"text[-\s]*to[-\s]*speech|tts|"
+ r"standardantwort|standardphrase|" # i18n-allow: input-matching data
+ r"jarvis\s+sagt|" # i18n-allow: input-matching data
+ r"verstehst\s+du\s+was\s+ich\s+meine" # i18n-allow: input-matching data
r")\b",
re.IGNORECASE,
)
+# WEAK markers are everyday words. They mean meta-conversation ONLY when the
+# turn also points at the assistant itself ("dein Log", "warum sagst du das").
+_META_DEBUG_WEAK_RE = re.compile(
+ r"\b("
+ r"provider|brain|transkript|transcript|log|bug|debug|" # i18n-allow: input data
+ r"fehler|fallback|phrase" # i18n-allow: input-matching data
+ r")\b",
+ re.IGNORECASE,
+)
+
+# The turn points AT the assistant: a possessive about its output, its name, or
+# a second-person "you said" construction. Deliberately NOT a bare "du"/"you" —
+# every second request to an assistant contains one ("Kannst du das Log holen"),
+# which is exactly how an everyday word became a meta verdict.
+_ASSISTANT_SELF_REFERENCE_RE = re.compile(
+ r"(?:"
+ r"\bdein\w*\b" # i18n-allow: input-matching data
+ r"|\bjarvis\b"
+ r"|\byour\b|\byours\b"
+ r"|\bdu\s+(?:sagst|sagtest|antwortest|meinst)\b" # i18n-allow: input data
+ r"|\b(?:sagst|sagtest|antwortest|meinst)\s+du\b" # i18n-allow: input data
+ r"|\b(?:hast|hattest)\s+du\b.{0,40}?\bgesagt\b" # i18n-allow: input data
+ r"|\byou\s+(?:said|say|keep\s+saying|answered|replied)\b"
+ r"|\btu\s+respuesta\b"
+ r")",
+ re.IGNORECASE,
+)
+
_INSTRUCTIONAL_QUESTION_RE = re.compile(
r"^\s*(?:"
r"wie\s+(?:kann|koennte|könnte|muss|soll|mach|mache|macht|geht|funktioniert)\s+" # i18n-allow: German input-matching data (instructional-question classifier)
@@ -155,6 +197,54 @@ _INSTRUCTIONAL_QUESTION_RE = re.compile(
re.IGNORECASE,
)
+# Clause break inside one spoken turn: punctuation or a coordinating particle.
+_CLAUSE_BREAK_RE = re.compile(
+ r"[,;:.!?]+"
+ r"|\b(?:und|aber|dann|jetzt|also)\b" # i18n-allow: input-matching data
+ r"|\b(?:and|but|then|now)\b"
+ r"|\b(?:y|pero|luego|ahora)\b", # i18n-allow: input-matching data
+ re.IGNORECASE,
+)
+
+# Bare 2nd-person imperative stems (DE/EN/ES). German infinitives are NOT
+# listed and cannot match: "oeffnen"/"machen" have no word boundary after # i18n-allow
+# imperative stem, so only the real command form ("oeffne", "mach") hits.
+_IMPERATIVE_VERB_RE = re.compile(
+ r"\b("
+ r"mach|mache|oeffne|öffne|starte|beende|" # i18n-allow: input-matching data
+ r"schliess|schließ|schliesse|schließe|" # i18n-allow: input-matching data
+ r"stopp|stoppe|pausier|pausiere|spiel|spiele|" # i18n-allow: input data
+ r"zeig|zeige|lies|schick|schicke|" # i18n-allow: input-matching data
+ r"schreib|schreibe|loesch|lösch|loesche|lösche|" # i18n-allow: input data
+ r"installier|installiere|kopier|kopiere|" # i18n-allow: input-matching data
+ r"klick|klicke|tipp|tippe|drueck|drück|" # i18n-allow: input-matching data
+ r"wechsle|wechsel|setz|setze|stell|stelle|" # i18n-allow: input data
+ r"leg|lege|hol|hole|nimm|geh|fahr|fahre|" # i18n-allow: input-matching data
+ r"aktivier|aktiviere|deaktivier|deaktiviere|" # i18n-allow: input data
+ r"open|close|restart|reboot|run|launch|play|send|install|uninstall|delete|"
+ r"remove|click|type|switch|show|list|turn|stop|start|"
+ r"abre|cierra|inicia|reinicia|ejecuta|envia|envía|" # i18n-allow: input data
+ r"borra|instala|pon|haz|muestra|reproduce" # i18n-allow: input data
+ r")\b",
+ re.IGNORECASE,
+)
+
+# German 1st-person indicative shares its form with the imperative ("starte"),
+# so "…und wie starte ICH das neu?" would otherwise read as a command. A # i18n-allow
+# imperative never carries an explicit subject pronoun.
+_INDICATIVE_SUBJECT_RE = re.compile(
+ r"\s*(?:ich|man|wir|i|we|you|yo|uno)\b", # i18n-allow: input data
+ re.IGNORECASE,
+)
+
+# English puts the subject in FRONT of the verb ("…and how do I restart it?"),
+# and an infinitive marker reads the same way ("to open"). Either kills the
+# imperative reading just as an explicit German subject does.
+_INDICATIVE_SUBJECT_BEFORE_RE = re.compile(
+ r"\b(?:i|you|we|they|to|ich|man|wir|zu|que)\s+$", # i18n-allow: input data
+ re.IGNORECASE,
+)
+
# Self-identification patterns: user introduces themselves (name, salutation, pronouns).
# These utterances must NEVER trigger side-effect tools — the Curator
# (jarvis/memory/curator/) extracts the facts automatically in the background
@@ -195,6 +285,26 @@ _SIDE_EFFECT_TOOL_NAMES = {
}
+# Possessive markers (DE/EN/ES). "Analysier MEINE Cloud-Kosten" asks about the
+# user's OWN resources — the one thing action tools exist for — and is never
+# literature research. Restricted to true possessives on purpose: "mir"/"ich"
+# would swallow the guard's own baseline case ("Vergleiche MIR mal, was ICH bei
+# Google Cloud verbraucht habe"), and "mein\w*" would match the verb "meinst".
+_POSSESSIVE_OWN_DATA_RE = re.compile(
+ r"\b("
+ r"mein(?:e|es|er|em|en)?|unser(?:e|es|er|em|en)?|" # i18n-allow: input data
+ r"my|mine|our|ours|"
+ r"mi|mis|nuestr[oa]s?" # i18n-allow: input-matching data
+ r")\b",
+ re.IGNORECASE,
+)
+
+
+def _is_own_data_request(utterance: str) -> bool:
+ """True when the utterance claims the data as the user's own."""
+ return bool(_POSSESSIVE_OWN_DATA_RE.search(utterance or ""))
+
+
def _is_research_intent(utterance: str, intent_level: str | None = None) -> bool:
"""Heuristic: does the utterance text indicate a pure research intent?
@@ -209,8 +319,21 @@ def _is_research_intent(utterance: str, intent_level: str | None = None) -> bool
def _is_meta_debug_intent(utterance: str) -> bool:
- """User is talking about Jarvis/provider behaviour, not about a task."""
- return bool(_META_DEBUG_KEYWORDS.search(utterance or ""))
+ """User is talking about Jarvis/provider behaviour, not about a task.
+
+ A strong marker decides on its own; an everyday word only counts when the
+ turn also points at the assistant. Without that second condition "Zeig mir
+ den Fehler im Log und starte den Dienst neu" read as a complaint # i18n-allow
+ about the assistant, and the turn ended on the canned acknowledgement
+ instead of doing the work.
+ """
+ text = utterance or ""
+ if _META_DEBUG_STRONG_RE.search(text):
+ return True
+ return bool(
+ _META_DEBUG_WEAK_RE.search(text)
+ and _ASSISTANT_SELF_REFERENCE_RE.search(text)
+ )
# Spoken fallback phrases, localized. Live bug 2026-06-10 23:13
@@ -267,9 +390,42 @@ def _meta_debug_ack_phrase(user_utterance: str, reply_language: str = "auto") ->
return _localized_phrase(_META_DEBUG_ACK_PHRASES, user_utterance, reply_language)
+def _has_trailing_imperative(utterance: str) -> bool:
+ """True when a command follows the question inside the SAME turn.
+
+ Only the part after the FIRST clause break is searched. In "How do I open
+ Spotify?" the verb belongs to the question itself and must not defuse the
+ guard. In "Warum ist Spotify nicht offen, mach es auf" the order # i18n-allow
+ sits behind the comma, and it is what the user actually wants done.
+ """
+ parts = _CLAUSE_BREAK_RE.split(utterance or "", maxsplit=1)
+ if len(parts) < 2:
+ return False
+ tail = parts[1]
+ for match in _IMPERATIVE_VERB_RE.finditer(tail):
+ if _INDICATIVE_SUBJECT_RE.match(tail, match.end()):
+ continue
+ if _INDICATIVE_SUBJECT_BEFORE_RE.search(tail[:match.start()]):
+ continue
+ return True
+ return False
+
+
def _is_instructional_question(utterance: str) -> bool:
- """User is asking for an explanation or how-to, not for execution."""
- return bool(_INSTRUCTIONAL_QUESTION_RE.search(utterance or ""))
+ """User is asking for an explanation or how-to, not for execution.
+
+ The question opener alone is not enough. "Warum ist Spotify nicht # i18n-allow
+ offen, mach es auf" opens with a question word and still ends in an # i18n-allow
+ order; blocking every side-effect tool on the opener meant that order
+ could never run — the user said something and nothing happened. The
+ guard therefore stands down as soon as a command follows the question
+ in the same turn. A pure how-to carries no such command and stays
+ blocked ("Wie kann ich bei Windows reinzoomen?"). # i18n-allow
+ """
+ text = utterance or ""
+ if not _INSTRUCTIONAL_QUESTION_RE.search(text):
+ return False
+ return not _has_trailing_imperative(text)
def _is_self_identification(utterance: str) -> bool:
@@ -316,11 +472,20 @@ def _should_block_action_as_research(
outcome is the unverified-answer fallback (trace 5edf0245). The override is
scoped to the mandated tool only, so other action tools stay blocked under
a research intent.
+
+ A possessive is the second stand-down. The guard's premise is that the user
+ wants information *about* a topic, not a query against their own system —
+ "Analysier meine Cloud-Kosten" is the exact opposite, and blocking every
+ cli_*/MCP tool there left the request unanswerable unless the evidence gate
+ happened to mandate that one tool. A request that names the data as the
+ user's own is an action on their own resources, not literature research.
"""
if tool is None or not _is_action_tool(tool):
return False
if tool_name and tool_name == evidence_required_tool:
return False
+ if _is_own_data_request(user_utterance):
+ return False
return _is_research_intent(user_utterance, intent_level)
@@ -778,6 +943,9 @@ class ToolUseLoop:
# Execute tools
suppress_output: str | None = None
+ # Held back until the whole round is done: a canned line may only
+ # end the turn when nothing else in it produced a result.
+ meta_debug_ack: str | None = None
unknown_tool_requested = False
for tc in agg.tool_calls:
tool_name = tc.get("name", "")
@@ -869,7 +1037,20 @@ class ToolUseLoop:
)
tool_result_payload = {"error": f"Tool '{tool_name}' not available"}
unknown_tool_requested = True
- elif tool_name == "spawn_worker" and _is_meta_debug_intent(user_utterance):
+ elif (
+ tool_name == "spawn_worker"
+ and _is_meta_debug_intent(user_utterance)
+ # A turn that names the vehicle out loud ("spawn an agent
+ # that finds out why the fallback fired") is a delegation
+ # request, not meta-conversation. The explicit-delegation
+ # gate below stays the authority on whether it may run;
+ # this guard only stops the model from delegating a
+ # conversation the user wanted answered. ``names_spawn_
+ # vehicle`` is the pure form of that test — calling
+ # ``llm_spawn_allowed`` here would consume the offer window
+ # a second time in the same turn.
+ and not names_spawn_vehicle(user_utterance)
+ ):
log.info(
"tool_use_loop: spawn_worker blocked for a meta/debug utterance"
)
@@ -892,7 +1073,12 @@ class ToolUseLoop:
# with a neutral acknowledgement so the user always hears
# *something*, and let the LLM weigh in next turn instead
# of stalling this one.
- suppress_output = _meta_debug_ack_phrase(
+ #
+ # Only ever a LAST resort: parked here and applied after
+ # the round (see below), because it ends the turn — and it
+ # used to do so even when another call in the same round
+ # had already succeeded, throwing that work away.
+ meta_debug_ack = _meta_debug_ack_phrase(
user_utterance, reply_language
)
tool_result_payload = {
@@ -1158,6 +1344,19 @@ class ToolUseLoop:
images=tuple(_img_blocks),
))
+ # The meta/debug acknowledgement ends the turn on a canned line, so
+ # it may only speak when this turn produced nothing else. A round
+ # that ran run_shell successfully AND requested a spawn used to end
+ # on "Verstanden. Was genau hätte anders sein sollen?", the # i18n-allow
+ # shell result was discarded, and the user heard nothing of the work
+ # that DID happen. Same rule as the missing-tool fallback below.
+ if (
+ meta_debug_ack is not None
+ and suppress_output is None
+ and not final_agg.executed_tool_names
+ ):
+ suppress_output = meta_debug_ack
+
# A missing tool is a full-turn refusal only when nothing else ran.
# In a multi-call round, one stale/model-invented name must never
# overwrite successful evidence from another call with the generic
diff --git a/tests/unit/brain/test_tool_use_loop_everyday_words.py b/tests/unit/brain/test_tool_use_loop_everyday_words.py
new file mode 100644
index 0000000000..a183d33bc7
--- /dev/null
+++ b/tests/unit/brain/test_tool_use_loop_everyday_words.py
@@ -0,0 +1,277 @@
+"""Everyday German words must not disarm the tool loop.
+
+Three deterministic guards in ``jarvis/brain/tool_use_loop.py`` keyed on plain
+vocabulary, so ordinary work turns were refused:
+
+* the how-to guard fired on any turn that merely OPENED with a question word,
+ so the command behind it ("Warum ist Spotify nicht offen, mach es auf") # i18n-allow
+ could never run;
+* the meta/debug guard read "fehler", "log", "bug", "provider", "brain" and # i18n-allow
+ "phrase" as talk about the assistant, and its canned acknowledgement ended
+ the whole turn even when another tool in the same round had succeeded;
+* the research guard blocked every ``cli_*``/MCP tool on a research verb, so a
+ request for the user's OWN data ("Analysier meine Cloud-Kosten") could not
+ read that data unless the evidence gate had mandated that exact tool.
+
+Each test below pins BOTH directions: the false block is gone and the original
+protection still fires.
+"""
+from __future__ import annotations
+
+from collections.abc import AsyncIterator
+from typing import Any
+
+import pytest
+
+from jarvis.brain.spawn_gate import OFFER_WINDOW
+from jarvis.brain.tool_use_loop import (
+ ToolUseLoop,
+ _is_instructional_question,
+ _is_meta_debug_intent,
+ _should_block_action_as_research,
+)
+from jarvis.core.protocols import BrainDelta, BrainRequest, ToolResult
+
+
+class _NamedTool:
+ schema: dict[str, Any] = {}
+
+ def __init__(self, name: str) -> None:
+ self.name = name
+
+
+class _McpActionTool:
+ name = "supabase/query"
+ is_action_tool = True
+ schema: dict[str, Any] = {}
+
+
+class _RecordingExecutor:
+ def __init__(self) -> None:
+ self.calls: list[str] = []
+
+ async def execute(self, tool: Any, args: dict[str, Any], **_: Any) -> ToolResult:
+ self.calls.append(tool.name)
+ return ToolResult(success=True, output=f"{tool.name} ok")
+
+
+class _CallsThenAnswerBrain:
+ """Emits the given tool calls in round 1, a plain answer afterwards."""
+
+ def __init__(self, calls: list[tuple[str, dict[str, Any]]]) -> None:
+ self._calls = calls
+ self.requests: list[BrainRequest] = []
+
+ async def complete(self, req: BrainRequest) -> AsyncIterator[BrainDelta]:
+ self.requests.append(req)
+ if len(self.requests) == 1:
+ for index, (name, args) in enumerate(self._calls):
+ yield BrainDelta(
+ tool_call={"id": f"c{index}", "name": name, "input": args}
+ )
+ yield BrainDelta(finish_reason="tool_use")
+ return
+ yield BrainDelta(content="Answer from the tool evidence.")
+ yield BrainDelta(finish_reason="stop")
+
+
+async def _run(
+ utterance: str,
+ calls: list[tuple[str, dict[str, Any]]],
+ tools: dict[str, Any],
+) -> tuple[list[str], str]:
+ OFFER_WINDOW.disarm()
+ brain = _CallsThenAnswerBrain(calls)
+ executor = _RecordingExecutor()
+ loop = ToolUseLoop(brain, tools, executor) # type: ignore[arg-type]
+ aggregate = await loop.run([], user_utterance=utterance)
+ return executor.calls, aggregate.text
+
+
+# --------------------------------------------------------------------------
+# GT-08 — a question opener must not cancel the command behind it
+# --------------------------------------------------------------------------
+
+
+async def test_question_opener_with_trailing_command_runs_the_command() -> None:
+ executed, text = await _run(
+ "Warum ist Spotify nicht offen, mach es auf", # i18n-allow: reported live utterance
+ [("open_app", {"app_name": "Spotify"})],
+ {"open_app": _NamedTool("open_app")},
+ )
+
+ assert executed == ["open_app"], "the imperative behind the question must run"
+ assert text == "Answer from the tool evidence."
+
+
+ "utterance",
+ [
+ "Warum ist Spotify nicht offen? Mach es auf.", # i18n-allow: same shape, sentence break
+ "Warum laeuft der Dienst nicht, starte ihn neu", # i18n-allow: German command turn
+ "Why is Spotify closed? Open it.",
+ "Warum ist der Ton weg, stell die Lautstaerke hoch", # i18n-allow: German command turn
+ ],
+)
+def test_command_after_the_question_stands_the_guard_down(utterance: str) -> None:
+ assert _is_instructional_question(utterance) is False
+
+
+ "utterance",
+ [
+ # The guard's own case: a pure how-to, no command anywhere.
+ "Wie kann ich bei Windows reinzoomen?", # i18n-allow: pinned how-to fixture
+ "Wie kann ich Spotify oeffnen?", # i18n-allow: infinitive, not an imperative
+ # The verb form is 1st-person indicative, not a command.
+ "Warum geht das nicht und wie starte ich es neu?", # i18n-allow: German how-to
+ "How do I open Spotify?",
+ "Why is this failing and how do I restart it?",
+ "Was ist ein Container?", # i18n-allow: definition question
+ ],
+)
+def test_pure_how_to_question_still_blocks(utterance: str) -> None:
+ assert _is_instructional_question(utterance) is True
+
+
+async def test_pure_how_to_question_still_blocks_the_side_effect_tool() -> None:
+ executed, _ = await _run(
+ "Wie kann ich bei Windows reinzoomen?", # i18n-allow: pinned how-to fixture
+ [("dispatch_to_harness", {"harness": "computer-use"})],
+ {"dispatch_to_harness": _NamedTool("dispatch_to_harness")},
+ )
+
+ assert executed == [], "a how-to question must not drive the desktop"
+
+
+# --------------------------------------------------------------------------
+# GT-09 — meta/debug words, and the canned acknowledgement
+# --------------------------------------------------------------------------
+
+
+ "utterance",
+ [
+ "Zeig mir den Fehler im Log und starte den Dienst neu", # i18n-allow
+ "Im Log steht ein Bug, schau dir das an", # i18n-allow: everyday German
+ "Der Provider in Frankfurt ist ausgefallen", # i18n-allow: everyday German
+ "Debug das Skript fuer mich", # i18n-allow: everyday German
+ ],
+)
+def test_everyday_words_are_not_meta_conversation(utterance: str) -> None:
+ assert _is_meta_debug_intent(utterance) is False
+
+
+ "utterance",
+ [
+ # Strong markers: assistant machinery, no everyday reading.
+ "Warum hat der Provider-Fallback gegriffen?", # i18n-allow: pinned meta fixture
+ "Deine Standardantwort nervt", # i18n-allow: German meta fixture
+ "Der API Key war doch gesetzt", # i18n-allow: German meta fixture
+ # Weak marker plus a turn that points at the assistant.
+ "Warum sagst du immer diese Phrase?", # i18n-allow: German meta fixture
+ "Dein Transkript stimmt hinten und vorne nicht", # i18n-allow: German meta fixture
+ ],
+)
+def test_meta_conversation_is_still_detected(utterance: str) -> None:
+ assert _is_meta_debug_intent(utterance) is True
+
+
+async def test_meta_utterance_alone_still_ends_on_the_acknowledgement() -> None:
+ """The guard's original protection: a meta turn must never be delegated,
+ and the user must hear something rather than run into the stream timeout."""
+ executed, text = await _run(
+ "Der Provider-Fallback hat schon wieder gegriffen", # i18n-allow: German meta fixture
+ [("spawn_worker", {"utterance": "investigate"})],
+ {"spawn_worker": _NamedTool("spawn_worker")},
+ )
+
+ assert executed == [], "a meta turn must not spawn a worker"
+ assert text and "?" in text, "the neutral acknowledgement must be spoken"
+
+
+async def test_acknowledgement_never_overwrites_a_successful_tool_result() -> None:
+ """The canned line ends the turn, so it may only speak when nothing else in
+ the turn produced a result. Previously a round that ran run_shell AND asked
+ for a spawn ended on the acknowledgement and threw the shell result away."""
+ executed, text = await _run(
+ "Der Provider-Fallback hat schon wieder gegriffen", # i18n-allow: German meta fixture
+ [
+ ("run_shell", {"cmd": "systemctl status"}),
+ ("spawn_worker", {"utterance": "investigate"}),
+ ],
+ {
+ "run_shell": _NamedTool("run_shell"),
+ "spawn_worker": _NamedTool("spawn_worker"),
+ },
+ )
+
+ assert executed == ["run_shell"], "the shell call must still run"
+ assert text == "Answer from the tool evidence."
+
+
+async def test_explicit_delegation_about_a_meta_topic_still_spawns() -> None:
+ """Naming the vehicle out loud is a delegation request, not a complaint."""
+ executed, _ = await _run(
+ "Spawne einen Agenten und finde raus, warum der Fallback griff", # i18n-allow
+ [("spawn_worker", {"utterance": "investigate"})],
+ {"spawn_worker": _NamedTool("spawn_worker")},
+ )
+
+ assert executed == ["spawn_worker"]
+
+
+# --------------------------------------------------------------------------
+# GT-10 — a request for the user's OWN data is not literature research
+# --------------------------------------------------------------------------
+
+
+ "utterance",
+ [
+ "Analysier meine Cloud-Kosten", # i18n-allow: reported live utterance
+ "Fass unsere offenen Rechnungen zusammen", # i18n-allow: German own-data turn
+ "Analyse my cloud spend",
+ "Analiza mis costes", # i18n-allow: Spanish own-data turn
+ ],
+)
+def test_own_data_request_is_not_blocked_as_research(utterance: str) -> None:
+ tool = _NamedTool("cli_gcloud")
+ assert _should_block_action_as_research(
+ tool, "cli_gcloud", utterance, "deep", evidence_required_tool=""
+ ) is False
+
+
+ ("utterance", "tool_name"),
+ [
+ # No possessive: the guard's premise (info ABOUT a topic) holds.
+ ("Erklaer mir mal Supabase", "supabase/query"), # i18n-allow: German research turn
+ ("Vergleiche mal die Cloud-Anbieter", "supabase/query"), # i18n-allow: German research turn
+ ("Explain how Postgres replication works", "supabase/query"),
+ ],
+)
+def test_research_without_a_possessive_is_still_blocked(
+ utterance: str, tool_name: str
+) -> None:
+ assert _should_block_action_as_research(
+ _McpActionTool(), tool_name, utterance, "deep", evidence_required_tool=""
+ ) is True
+
+
+async def test_own_data_request_reaches_the_cli_tool() -> None:
+ executed, text = await _run(
+ "Analysier meine Cloud-Kosten", # i18n-allow: reported live utterance
+ [("cli_gcloud", {"args": "billing list"})],
+ {"cli_gcloud": _NamedTool("cli_gcloud")},
+ )
+
+ assert executed == ["cli_gcloud"]
+ assert text == "Answer from the tool evidence."