fix: 已出号后新一轮询价不带上一单字段

点名海运时丢掉旧陆运补问草稿,避免补字段误发填写样例图。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-20 18:27:13 +08:00
co-authored by Cursor
parent b3b3cf2903
commit 19acbb9156
8 changed files with 256 additions and 9 deletions
+50 -1
View File
@@ -25,7 +25,7 @@ from agent.channel.wecom.models import InboundMessage
from agent.handlers.text_inquiry import handle_text_inquiry
from agent.policy.air_text_flow import reset_air_text_flow_for_test
from agent.policy.land_text_flow import get_land_text_flow, reset_land_text_flow_for_test
from agent.policy.sea_text_flow import reset_sea_text_flow_for_test
from agent.policy.sea_text_flow import get_sea_text_flow, reset_sea_text_flow_for_test
from agent.routing.decision import RouteDecision
from agent.routing.dispatch import dispatch_inbound
from tests.test_sea_text_inquiry import COMPLETE_SEA
@@ -323,6 +323,55 @@ class LandDispatchTests(unittest.TestCase):
self.assertNotIn("你好,我是询价机器人", last)
self.assertIn("请说明要调哪一项费用", last)
def test_sea_field_supplement_not_stolen_by_stale_land(self) -> None:
"""
旧陆运选项草稿不能抢走海运补问。
测服:先陆运缺选项,再发海运缺贸易条款/运输分类,下一句只补这两项,
不能回陆运「参数提取不全」或填写样例图。
"""
store = get_message_store()
handle_text_inquiry(
InboundMessage(sender_id="mix-sea", message_id="m-land-old", content="陆运询价"),
injected_facts={"起运港": "广州", "目的港": "深圳", "品名": "衣服"},
injected_mode="LAND",
store=store,
)
self.assertEqual(get_land_text_flow().session_of("mix-sea").phase, "need_land_options")
incomplete = {
"起运港": "上海",
"目的港": "洛杉矶",
"品名": "普货",
"货量": "20吨",
"整柜或拼柜": "整柜",
"箱型箱量": "1x40HQ",
}
phase = handle_text_inquiry(
InboundMessage(sender_id="mix-sea", message_id="m-sea-ask", content="海运询价"),
injected_facts=incomplete,
injected_mode="SEA",
store=store,
)
self.assertEqual(phase, "clarify")
self.assertEqual(get_sea_text_flow().session_of("mix-sea").phase, "clarify")
self.assertIsNone(get_land_text_flow().session_of("mix-sea"))
before = len(store._outbox)
phase = handle_text_inquiry(
InboundMessage(
sender_id="mix-sea",
message_id="m-sea-fill",
content="贸易条款:FOB 运输分类:其他",
),
injected_facts={"贸易条款": "FOB", "运输分类": "其他"},
store=store,
)
self.assertNotEqual(phase, "need_land_options")
self.assertEqual(get_sea_text_flow().session_of("mix-sea").business_line, "SEA")
added = "\n".join(i.content for i in list(store._outbox.values())[before:])
self.assertNotIn("参数提取不全", added)
self.assertNotIn("填写样例", added)
self.assertNotIn("运输类型", added)
def test_clarify_short_reply_misrouted_as_other_stays_on_inquiry(self) -> None:
"""补问阶段回「111」即使被标闲聊,也不能发开场白。"""
store = get_message_store()