Cache inventory MCP lists and accept YES as WhatsApp confirm.

Extend short TTL reuse to listManagedNe/queryUmeNeInventory to cut list self-loops, and treat short YES/continue as confirmation when a token is pending.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-10 22:56:50 +08:00
parent f1d025ed60
commit d3f621b58b
6 changed files with 130 additions and 42 deletions

View file

@ -26,6 +26,26 @@ def evaluate_risk(task: AgentTask) -> GuardrailResult:
return GuardrailResult(allowed=True, needs_confirmation=False, reason="Low-risk request")
_AFFIRMATIVE_SHORT = frozenset(
{
"yes",
"y",
"ok",
"okay",
"confirm",
"continue",
"please continue",
"go ahead",
"可以",
"确认",
"继续",
"好的",
"行",
"是",
}
)
def has_explicit_confirmation(user_text: str) -> bool:
return has_explicit_confirmation_token(user_text, token=None)
@ -48,6 +68,13 @@ def has_explicit_confirmation_token(user_text: str, token: str | None) -> bool:
return False
if f"[confirm:{t}]".lower() in low or f"confirm:{t}".lower() in low:
return True
# WhatsApp field: short YES/continue while a token is outstanding.
import re
compact = re.sub(r"@\S+", " ", low)
compact = " ".join(compact.split())
if compact in _AFFIRMATIVE_SHORT:
return True
return False