feat: add richer clarification replies for ambiguous customer intent

This commit is contained in:
2026-02-28 23:40:17 +08:00
parent 5b8ca6fb02
commit 3c77c618e7
2 changed files with 90 additions and 1 deletions

View File

@@ -139,6 +139,33 @@ class RegressionPipelineTest(unittest.IsolatedAsyncioTestCase):
self.assertIn("50", resp.reply)
agent._quote_pending_images.assert_awaited()
async def test_find_image_not_edit_conflict_triggers_clarification(self):
agent = CustomerServiceAgent()
st = agent._get_conversation_state(self.customer_id)
st.pending_image_urls = ["https://img.alicdn.com/a.jpg"]
st.pending_requirements = []
agent._sync_pending_quote_state(self.customer_id, st)
agent._quote_pending_images = AsyncMock(return_value={"reply": "不该触发", "need_transfer": False})
msg = CustomerMessage(
msg_id="m6",
acc_id="test_shop",
msg="我要你帮我找图,不是让你做图",
from_id=self.customer_id,
from_name="t",
cy_id=self.customer_id,
acc_type="AliWorkbench",
msg_type=0,
cy_name="t",
goods_name="专业找图",
goods_order="",
)
resp = await agent.process_message(msg)
self.assertTrue(resp.should_reply)
self.assertIn("找图", resp.reply)
self.assertIn("不是做图", resp.reply)
agent._quote_pending_images.assert_not_awaited()
async def test_pending_state_restore(self):
db.update_pending_quote_state(self.customer_id, ["u1", "u2"], ["r1"])
agent = CustomerServiceAgent()