mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 05:50:44 +08:00
Soften short-intent gates and add tool-result refs plus MCP wire invalidate.
Prefer report tools without hard-hiding CLI, keep soft CLI budgets, store compact+result_ref for the model, and clear frozen wire after MCP sync. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
3785e78a72
commit
605751b6a6
13 changed files with 636 additions and 65 deletions
|
|
@ -8,42 +8,50 @@ from typing import Any
|
|||
_BOT_MENTION_RE = re.compile(r"@\S+")
|
||||
|
||||
# intent -> (en hint, zh hint)
|
||||
# Prefer report path strongly; keep CLI/inventory available with soft budget (not hard-hidden).
|
||||
_HINTS: dict[str, tuple[str, str]] = {
|
||||
"excel_export": (
|
||||
"[Ops short-intent: Excel export. Call ume_alarm_xlsx_report(..., deliverable=true) now. "
|
||||
"write_xlsx / inventory / CLI / run_command are hidden this turn — do not build xlsx via shell.]",
|
||||
"[短指令:导出 Excel。立即 ume_alarm_xlsx_report(..., deliverable=true)。"
|
||||
"本轮已隐藏 write_xlsx/清单/CLI/run_command,禁止用 shell 搓表。]",
|
||||
"[Ops short-intent: Excel export. Prefer ume_alarm_xlsx_report(..., deliverable=true) now. "
|
||||
"write_xlsx / run_command are hidden this turn. "
|
||||
"CLI/inventory stay available with a soft budget for device checks — prefer one hetero targets batch, not single-NE loops.]",
|
||||
"[短指令:导出 Excel。优先 ume_alarm_xlsx_report(..., deliverable=true)。"
|
||||
"本轮已隐藏 write_xlsx/run_command。"
|
||||
"CLI/清单仍可用(soft budget):核实设备优先一次 hetero targets batch,勿单台循环。]",
|
||||
),
|
||||
"license": (
|
||||
"[Ops short-intent: license/capacity. Call ume_alarm_xlsx_report(mode=list, keyword=license, deliverable=true) "
|
||||
"or aggregateUmeAlarms/queryUmeAlarmsRaw; write_xlsx/CLI/inventory are hidden this turn.]",
|
||||
"[短指令:License/容量。立即 ume_alarm_xlsx_report(mode=list, keyword=license, deliverable=true) "
|
||||
"或 aggregate/queryUmeAlarmsRaw;本轮已隐藏 write_xlsx/CLI/清单。]",
|
||||
"[Ops short-intent: license/capacity. Prefer ume_alarm_xlsx_report(mode=list, keyword=license, deliverable=true) "
|
||||
"or aggregateUmeAlarms/queryUmeAlarmsRaw. write_xlsx/run_command hidden; "
|
||||
"CLI available with soft budget for confirmation (one targets batch preferred).]",
|
||||
"[短指令:License/容量。优先 ume_alarm_xlsx_report(mode=list, keyword=license, deliverable=true) "
|
||||
"或 aggregate/queryUmeAlarmsRaw;write_xlsx/run_command 已隐藏;"
|
||||
"CLI 可用(soft budget),确认阶段优先一次 targets batch。]",
|
||||
),
|
||||
"congestion": (
|
||||
"[Ops short-intent: bandwidth congestion. Call ume_alarm_xlsx_report(mode=list, deliverable=true) "
|
||||
"or aggregateUmeAlarms/queryUmeAlarmsRaw; write_xlsx/CLI/inventory/sql are hidden this turn.]",
|
||||
"[短指令:带宽拥塞。立即 ume_alarm_xlsx_report(mode=list, deliverable=true) 或 aggregate/query;"
|
||||
"本轮已隐藏 write_xlsx/CLI/清单/sql。]",
|
||||
"[Ops short-intent: bandwidth congestion. Prefer ume_alarm_xlsx_report(mode=list, deliverable=true) "
|
||||
"or aggregateUmeAlarms/queryUmeAlarmsRaw. write_xlsx/run_command hidden; "
|
||||
"CLI available with soft budget (one targets batch preferred).]",
|
||||
"[短指令:带宽拥塞。优先 ume_alarm_xlsx_report(mode=list, deliverable=true) 或 aggregate/query;"
|
||||
"write_xlsx/run_command 已隐藏;CLI 可用(soft budget),优先一次 targets batch。]",
|
||||
),
|
||||
"fiber_cut": (
|
||||
"[Ops short-intent: fiber/LOS. Call ume_alarm_xlsx_report(mode=fiber_cut, deliverable=true) now. "
|
||||
"write_xlsx / inventory / CLI are hidden this turn — do not try listCliTargets/execManagedNe/write_xlsx.]",
|
||||
"[短指令:断纤/LOS。立即 ume_alarm_xlsx_report(mode=fiber_cut, deliverable=true)。"
|
||||
"本轮已隐藏 write_xlsx/清单/CLI,勿调用 listCliTargets/execManagedNe/write_xlsx。]",
|
||||
"[Ops short-intent: fiber/LOS. Prefer ume_alarm_xlsx_report(mode=fiber_cut, deliverable=true) now. "
|
||||
"write_xlsx/run_command hidden. CLI/inventory available with soft budget — "
|
||||
"use at most one hetero targets batch for device confirmation, not listCliTargets→single-NE loops.]",
|
||||
"[短指令:断纤/LOS。优先 ume_alarm_xlsx_report(mode=fiber_cut, deliverable=true)。"
|
||||
"write_xlsx/run_command 已隐藏。CLI/清单可用(soft budget):"
|
||||
"设备核实最多一次 hetero targets batch,勿 listCliTargets→单台循环。]",
|
||||
),
|
||||
"offline": (
|
||||
"[Ops short-intent: offline NE. Call ume_alarm_xlsx_report(mode=offline, deliverable=true) now. "
|
||||
"write_xlsx / inventory / CLI are hidden this turn.]",
|
||||
"[短指令:离线网元。立即 ume_alarm_xlsx_report(mode=offline, deliverable=true)。"
|
||||
"本轮已隐藏 write_xlsx/清单/CLI。]",
|
||||
"[Ops short-intent: offline NE. Prefer ume_alarm_xlsx_report(mode=offline, deliverable=true) now. "
|
||||
"write_xlsx/run_command hidden; CLI/inventory with soft budget (one targets batch preferred).]",
|
||||
"[短指令:离线网元。优先 ume_alarm_xlsx_report(mode=offline, deliverable=true)。"
|
||||
"write_xlsx/run_command 已隐藏;CLI/清单 soft budget(优先一次 targets batch)。]",
|
||||
),
|
||||
"alarm_tally": (
|
||||
"[Ops short-intent: alarm tally/top. Call ume_alarm_xlsx_report(mode=aggregate_by_host, deliverable=true) "
|
||||
"or aggregateUmeAlarms; write_xlsx / inventory / CLI are hidden this turn.]",
|
||||
"[短指令:告警统计/Top。立即 ume_alarm_xlsx_report(mode=aggregate_by_host, deliverable=true) "
|
||||
"或 aggregateUmeAlarms;本轮已隐藏 write_xlsx/清单/CLI。]",
|
||||
"[Ops short-intent: alarm tally/top. Prefer ume_alarm_xlsx_report(mode=aggregate_by_host, deliverable=true) "
|
||||
"or aggregateUmeAlarms. write_xlsx/run_command hidden; CLI soft budget for spot checks.]",
|
||||
"[短指令:告警统计/Top。优先 ume_alarm_xlsx_report(mode=aggregate_by_host, deliverable=true) "
|
||||
"或 aggregateUmeAlarms;write_xlsx/run_command 已隐藏;CLI soft budget 仅作抽检。]",
|
||||
),
|
||||
"continue": (
|
||||
"[Ops short-intent: continue/confirm. Resume the unfinished prior task immediately; "
|
||||
|
|
@ -52,29 +60,21 @@ _HINTS: dict[str, tuple[str, str]] = {
|
|||
),
|
||||
}
|
||||
|
||||
# Report-style short intents: hide inventory/CLI loops that dominate WA tool spam.
|
||||
# Report-style short intents: soft-nudge toward alarm/xlsx; hide only shell/xlsx DIY.
|
||||
_REPORT_TOOL_FILTER_INTENTS = frozenset(
|
||||
{"fiber_cut", "offline", "alarm_tally", "excel_export", "license", "congestion"}
|
||||
)
|
||||
|
||||
# Match bare tool names and mcp__netx__* / legacy netx_* aliases.
|
||||
# Soft CLI budgets during report short-intents (prefer report; allow limited device checks).
|
||||
_SHORT_INTENT_CLI_SOFT_SINGLE = 2
|
||||
_SHORT_INTENT_CLI_SOFT_FAIL = 2
|
||||
_SHORT_INTENT_CLI_SOFT_BATCH = 1
|
||||
|
||||
# Only hard-hide DIY spreadsheet / shell paths — keep inventory + execManagedNe visible.
|
||||
_SUPPRESSED_TOOL_NAMES = frozenset(
|
||||
{
|
||||
"listclitargets",
|
||||
"listmanagedne",
|
||||
"getmanagedne",
|
||||
"execmanagedne",
|
||||
"queryumeneinventory",
|
||||
"getumene",
|
||||
"findtopologypaths",
|
||||
"sqlqueryume",
|
||||
"run_command",
|
||||
"write_xlsx",
|
||||
"netx_list_managed_ne",
|
||||
"netx_get_managed_ne",
|
||||
"netx_exec_managed_ne",
|
||||
"netx_sql_query_ume",
|
||||
"netx_list_cli_targets",
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -93,6 +93,17 @@ def ops_short_intent_should_filter_tools(intent: str | None) -> bool:
|
|||
return str(intent or "").strip() in _REPORT_TOOL_FILTER_INTENTS
|
||||
|
||||
|
||||
def ops_short_intent_cli_soft_budgets(intent: str | None) -> dict[str, int] | None:
|
||||
"""Tighter execManagedNe budgets for report short-intents; None = use global defaults."""
|
||||
if not ops_short_intent_should_filter_tools(intent):
|
||||
return None
|
||||
return {
|
||||
"single": int(_SHORT_INTENT_CLI_SOFT_SINGLE),
|
||||
"fail": int(_SHORT_INTENT_CLI_SOFT_FAIL),
|
||||
"batch": int(_SHORT_INTENT_CLI_SOFT_BATCH),
|
||||
}
|
||||
|
||||
|
||||
def is_ops_short_intent_suppressed_tool(tool_name: str, *, intent: str | None) -> bool:
|
||||
if not ops_short_intent_should_filter_tools(intent):
|
||||
return False
|
||||
|
|
@ -101,7 +112,7 @@ def is_ops_short_intent_suppressed_tool(tool_name: str, *, intent: str | None) -
|
|||
|
||||
|
||||
def filter_tool_specs_for_ops_short_intent(tools: list[Any], *, intent: str | None) -> list[Any]:
|
||||
"""Drop inventory/CLI tools for report-style short intents (keep alarm/xlsx path)."""
|
||||
"""Drop DIY xlsx/shell tools for report-style short intents (keep alarm path + CLI)."""
|
||||
if not ops_short_intent_should_filter_tools(intent):
|
||||
return list(tools or [])
|
||||
out: list[Any] = []
|
||||
|
|
@ -188,5 +199,6 @@ __all__ = [
|
|||
"is_ops_short_intent_suppressed_tool",
|
||||
"maybe_ops_short_intent_system_hint",
|
||||
"normalize_ops_user_text",
|
||||
"ops_short_intent_cli_soft_budgets",
|
||||
"ops_short_intent_should_filter_tools",
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue