Hide inventory/CLI tools on WhatsApp report short-intents.

Fiber/offline/alarm/excel/license/congestion turns drop list/exec/sql/run_command so the model must use ume_alarm_xlsx_report instead of inventory self-loops.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-10 23:45:30 +08:00
parent 6c5536b758
commit dff8901ae3
3 changed files with 157 additions and 24 deletions

View file

@ -3,10 +3,13 @@ from __future__ import annotations
from runtime.application.gateway.ops_short_intent import (
build_group_mention_nudge_text,
detect_ops_short_intent,
filter_tool_specs_for_ops_short_intent,
is_ops_short_intent_suppressed_tool,
maybe_ops_short_intent_system_hint,
reset_group_mention_nudge_throttle_for_tests,
should_send_group_mention_nudge,
)
from runtime.tools.base import ToolSpec
from runtime.tools.tool_error_hints import enrich_exec_managed_ne_error
@ -43,6 +46,43 @@ def test_group_mention_nudge_throttle() -> None:
)
def test_ops_short_intent_suppresses_inventory_cli_tools() -> None:
assert is_ops_short_intent_suppressed_tool("mcp__netx__listCliTargets", intent="fiber_cut")
assert is_ops_short_intent_suppressed_tool("mcp__netx__execManagedNe", intent="offline")
assert is_ops_short_intent_suppressed_tool("run_command", intent="excel_export")
assert not is_ops_short_intent_suppressed_tool("ume_alarm_xlsx_report", intent="fiber_cut")
assert not is_ops_short_intent_suppressed_tool("mcp__netx__queryUmeAlarmsRaw", intent="alarm_tally")
assert not is_ops_short_intent_suppressed_tool("mcp__netx__execManagedNe", intent="continue")
def test_filter_tool_specs_for_ops_short_intent_keeps_report_path() -> None:
def _spec(name: str) -> ToolSpec:
return ToolSpec(
name=name,
description="t",
parameters={"type": "object", "properties": {}},
handler=lambda _a: {"ok": True},
)
tools = [
_spec("mcp__netx__listCliTargets"),
_spec("mcp__netx__execManagedNe"),
_spec("ume_alarm_xlsx_report"),
_spec("mcp__netx__aggregateUmeAlarms"),
_spec("write_xlsx"),
_spec("run_command"),
]
kept = filter_tool_specs_for_ops_short_intent(tools, intent="fiber_cut")
names = {t.name for t in kept}
assert "ume_alarm_xlsx_report" in names
assert "mcp__netx__aggregateUmeAlarms" in names
assert "write_xlsx" in names
assert "mcp__netx__listCliTargets" not in names
assert "mcp__netx__execManagedNe" not in names
assert "run_command" not in names
assert len(filter_tool_specs_for_ops_short_intent(tools, intent="continue")) == len(tools)
def test_ops_short_intent_hint_english_default() -> None:
hint = maybe_ops_short_intent_system_hint(text="LOS on these sites", lang="en")
assert "fiber" in hint.lower() or "LOS" in hint