落地系统异常:大模型/TMS/建群故障停住本单并告警,后台可重试失败步骤。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -183,27 +183,31 @@ class LandDispatchTests(unittest.TestCase):
|
||||
last = list(store._outbox.values())[-1].content
|
||||
self.assertNotIn("你好,我是询价机器人", last)
|
||||
|
||||
def test_tms_retry_misrouted_as_other(self) -> None:
|
||||
def test_tms_tech_fail_pauses_until_admin_retry(self) -> None:
|
||||
from agent.policy.inquiry_copy import SYS_EXC_TMS_FALLBACK
|
||||
from tests.test_land_text_inquiry import CountingLedger
|
||||
|
||||
class Flaky(CountingLedger):
|
||||
class AlwaysFail(CountingLedger):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.query_calls = 0
|
||||
|
||||
def query_tms(self, **kwargs):
|
||||
self.query_calls += 1
|
||||
if self.query_calls == 1:
|
||||
return {
|
||||
"ok": False,
|
||||
"classification": "TMS_TECH_FAILURE",
|
||||
"has_price": False,
|
||||
"quote": {},
|
||||
}
|
||||
return super().query_tms(**kwargs)
|
||||
return {
|
||||
"ok": False,
|
||||
"classification": "TMS_TECH_FAILURE",
|
||||
"has_price": False,
|
||||
"quote": {},
|
||||
}
|
||||
|
||||
land = reset_land_text_flow_for_test()
|
||||
land.ledger = Flaky()
|
||||
ledger = AlwaysFail()
|
||||
land.ledger = ledger
|
||||
get_sea_text_flow().ledger = ledger
|
||||
from agent.policy.air_text_flow import get_air_text_flow
|
||||
|
||||
get_air_text_flow().ledger = ledger
|
||||
facts = {
|
||||
"起运港": "广州",
|
||||
"目的港": "深圳",
|
||||
@@ -231,18 +235,27 @@ class LandDispatchTests(unittest.TestCase):
|
||||
InboundMessage(sender_id="ld5", message_id="m-l5c", content="确定"),
|
||||
store=self.store,
|
||||
)
|
||||
self.assertEqual(get_land_text_flow().session_of("ld5").phase, "tms_tech")
|
||||
wo = get_land_text_flow().session_of("ld5").work_order_no
|
||||
self.assertGreaterEqual(ledger.query_calls, 3)
|
||||
wo = ledger.last_created_no
|
||||
ticket = ledger.get_ticket(work_order_no=wo)
|
||||
self.assertEqual(ticket.system_exception, "TMS异常")
|
||||
bodies = "\n".join(i.content for i in self.store._outbox.values())
|
||||
self.assertIn(SYS_EXC_TMS_FALLBACK, bodies)
|
||||
self.assertIsNone(get_land_text_flow().session_of("ld5"))
|
||||
name = dispatch_inbound(
|
||||
InboundMessage(sender_id="ld5", message_id="m-l5d", content="确定"),
|
||||
RouteDecision(intent="ordinary_text_other"),
|
||||
)
|
||||
self.assertEqual(name, "ordinary_text_inquiry")
|
||||
self.assertEqual(name, "ordinary_text_other")
|
||||
sess = get_land_text_flow().session_of("ld5")
|
||||
self.assertEqual(sess.phase, "wait_collab")
|
||||
self.assertEqual(sess.work_order_no, wo)
|
||||
if sess is not None:
|
||||
self.assertNotEqual(sess.phase, "wait_collab")
|
||||
handle_text_inquiry(
|
||||
InboundMessage(sender_id="ld5", message_id="m-l5e", content=f"看看 {wo}"),
|
||||
store=self.store,
|
||||
)
|
||||
last = list(self.store._outbox.values())[-1].content
|
||||
self.assertNotIn("你好,我是询价机器人", last)
|
||||
self.assertIn(SYS_EXC_TMS_FALLBACK, last)
|
||||
|
||||
def test_sea_still_creates_immediately(self) -> None:
|
||||
msg = InboundMessage(sender_id="s-sea", message_id="m-sea-keep", content="海运询价")
|
||||
|
||||
Reference in New Issue
Block a user