mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 04:40:45 +08:00
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:
parent
f1d025ed60
commit
d3f621b58b
6 changed files with 130 additions and 42 deletions
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue