Dedupe WhatsApp access pending and cap execManagedNe per turn.

Reuse open pending requests without re-notifying admins, clarify already-waiting replies, and block further CLI after 4 calls or 2 failures in the same turn.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-10 23:25:09 +08:00
parent d8bc08ee0d
commit 28a5f2586c
6 changed files with 332 additions and 27 deletions

View file

@ -343,15 +343,25 @@ def coerce_whatsapp_access_target(value: str) -> str:
return normalize_whatsapp_target(normalize_whatsapp_phone(value))
def denied_reply_text(*, lang: str, pending_id: str = "") -> str:
def denied_reply_text(*, lang: str, pending_id: str = "", already_pending: bool = False) -> str:
pid = str(pending_id or "").strip()
if str(lang or "").strip().lower().startswith("zh"):
if already_pending and pid:
return (
f"访问申请仍在等待管理员处理(编号 {pid})。"
"同意后即可使用;请稍候,无需重复发送。"
)
if pid:
return (
f"访问申请已提交(编号 {pid})。管理员同意后即可使用;"
"请稍候,无需重复发送相同请求。"
)
return "无权限:您尚未获得使用此助手的授权。请联系管理员。"
if already_pending and pid:
return (
f"Your access request is still pending (request {pid}). "
"An administrator was already notified — please wait for YES; no need to resend."
)
if pid:
return (
f"Access pending (request {pid}): an administrator was notified. "