mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 09:10:46 +08:00
Steer WhatsApp ops short intents and clarify busy/CLI failures.
Inject English recipe hints for fiber/offline/excel/continue, ack the first queued follow-up, localize gate copy, and classify execManagedNe errors so agents stop blind retries. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
47fd83597e
commit
f1d025ed60
8 changed files with 323 additions and 11 deletions
41
tests/test_ops_short_intent_and_exec_hints.py
Normal file
41
tests/test_ops_short_intent_and_exec_hints.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from runtime.application.gateway.ops_short_intent import (
|
||||
detect_ops_short_intent,
|
||||
maybe_ops_short_intent_system_hint,
|
||||
)
|
||||
from runtime.tools.tool_error_hints import enrich_exec_managed_ne_error
|
||||
|
||||
|
||||
def test_detect_ops_short_intent_english_field() -> None:
|
||||
assert detect_ops_short_intent("@bot fiber cut sites") == "fiber_cut"
|
||||
assert detect_ops_short_intent("offline NE list") == "offline"
|
||||
assert detect_ops_short_intent("please continue") == "continue"
|
||||
assert detect_ops_short_intent("YES") == "continue"
|
||||
assert detect_ops_short_intent("export excel") == "excel_export"
|
||||
assert detect_ops_short_intent("critical top alarms") == "alarm_tally"
|
||||
assert detect_ops_short_intent("hello there how are you doing today with something else") is None
|
||||
|
||||
|
||||
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
|
||||
assert "ume_alarm_xlsx_report" in hint
|
||||
assert "断纤" not in hint
|
||||
|
||||
|
||||
def test_enrich_exec_timeout() -> None:
|
||||
out = enrich_exec_managed_ne_error(
|
||||
{"ok": False, "error_code": "tool_timeout_or_failed", "error": "timeout"}
|
||||
)
|
||||
assert out["error_class"] == "timeout"
|
||||
assert "read_timeout_sec" in out["hint"]
|
||||
|
||||
|
||||
def test_enrich_exec_unreachable_nested_json() -> None:
|
||||
nested = '{"ok": false, "error": "ssh_connect failed: host unreachable"}'
|
||||
out = enrich_exec_managed_ne_error(
|
||||
{"ok": False, "error_code": "mcp_tool_call_failed", "error": nested}
|
||||
)
|
||||
assert out["error_class"] == "unreachable"
|
||||
assert "unreachable" in out["hint"].lower()
|
||||
|
|
@ -36,3 +36,10 @@ def test_enrich_mcp_scope_sql() -> None:
|
|||
assert out["required_scope"] == "sql:query"
|
||||
assert "fallback_tools" in out
|
||||
assert "ume_alarm_xlsx_report" in out["fallback_tools"]
|
||||
|
||||
|
||||
def test_enrich_exec_auth() -> None:
|
||||
from runtime.tools.tool_error_hints import enrich_exec_managed_ne_error
|
||||
|
||||
out = enrich_exec_managed_ne_error({"ok": False, "error": "authentication failed: Permission denied"})
|
||||
assert out["error_class"] == "auth"
|
||||
|
|
|
|||
|
|
@ -235,10 +235,19 @@ class WhatsappInboundSerialQueueTests(unittest.TestCase):
|
|||
pending = self.store.list_pending_channel_outbound_messages(
|
||||
channel="whatsapp", account_id="wa-default", limit=10
|
||||
)
|
||||
self.assertEqual(len(pending), 2)
|
||||
self.assertEqual(len(pending), 3)
|
||||
texts = " ".join(str(p.get("text") or "") for p in pending)
|
||||
self.assertIn("ans:1", texts)
|
||||
self.assertIn("ans:2", texts)
|
||||
self.assertIn("Still working", texts)
|
||||
kinds = []
|
||||
for p in pending:
|
||||
try:
|
||||
kinds.append(json.loads(str(p.get("source") or "{}")).get("kind"))
|
||||
except Exception:
|
||||
kinds.append(None)
|
||||
self.assertIn("inbound_progress", kinds)
|
||||
self.assertEqual(kinds.count("inbound_reply"), 2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue