落地转人工:三次补问或明确接管后出入口,真正转人工后冻结本票并允许新开询价。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-20 16:42:13 +08:00
co-authored by Cursor
parent 26dd5d72a1
commit 7eedf28e8d
23 changed files with 1499 additions and 132 deletions
@@ -70,6 +70,9 @@ def _prepare_model_tool_args(
if intent == "quote_adjust" or action_type == "QUOTE_ADJUST":
data["intent"] = "quote_adjust"
action["action_type"] = "QUOTE_ADJUST"
if intent == "handoff_human" or action_type == "HANDOFF_HUMAN":
data["intent"] = "handoff_human"
action["action_type"] = "HANDOFF_HUMAN"
target = action.get("target") if isinstance(action.get("target"), dict) else {}
wo = str(target.get("work_order_no") or "").strip()
if data.get("intent") == "continue_thread" and not wo:
@@ -101,10 +104,14 @@ _SYSTEM = (
"原话在描述新的运输需求(港口/机场、货物、件数重量体积、空运海运陆运等),"
"即使偶尔拿旧单号当参考,也走新询价,work_order_no 留空。"
"陆运核对卡之后回复确定、确认、查价、可以查了,仍是新询价,禁止标闲聊。"
"机器人正在补问缺项时,销售只回件数、品名、重量、体积等短答(如 111、3件),仍是新询价续填,禁止标闲聊。"
"【调价】intent=quote_adjust,action_type=QUOTE_ADJUST。"
"inbound_facts 里 session_quoted=true 时,销售用自然语言改当前已有报价:"
"涨、跌、加、减、上升、上浮、往上抬、改到某金额、在现有报价基础上调整,口令不写死。"
"只说报价/总价、没点名费用,仍是调价,不是闲聊也不是新询价。"
"【转人工】intent=handoff_human,action_type=HANDOFF_HUMAN。"
"销售明确要求人来报价或接管:转人工、人工报价、找产品/航线、别自动查了、不要机器人了。"
"口令不写死。抱怨慢、骂两句、只问进度不算,那些仍走新询价或闲聊。"
"【闲聊】intent=ordinary_text_other,action_type=ORDINARY_TEXT_OTHER。"
"问候、谢谢、无关闲聊。点卡片按钮字(生成Excel/生成PDF/不采用等)也标闲聊。"
"禁止因为销售没说指定口令就把续办或调价判成新询价或闲聊。"
+15 -1
View File
@@ -16,7 +16,12 @@ from agent.handlers.echo_text import handle_echo_text
from agent.handlers.group_collab import handle_group_collab
from agent.handlers.image_inquiry import handle_image_inquiry
from agent.handlers.attachment_inquiry import handle_attachment_inquiry
from agent.handlers.text_inquiry import handle_text_inquiry, handle_text_other, is_land_confirm_action
from agent.handlers.text_inquiry import (
handle_text_inquiry,
handle_text_other,
is_land_confirm_action,
should_resume_other_as_inquiry,
)
from agent.routing.decision import RouteDecision
logger = logging.getLogger(__name__)
@@ -124,6 +129,7 @@ HANDLER_REGISTRY: dict[str, HandlerFn] = {
"ordinary_text_inquiry": _wrap_text_inquiry,
"ordinary_text_other": _wrap_text_other,
"quote_adjust": _wrap_text_inquiry,
"handoff_human": _wrap_text_inquiry,
"attachment_inquiry": _wrap_attachment,
"image_inquiry": _wrap_image,
"multi_segment_transport": _wrap_new,
@@ -263,10 +269,18 @@ def dispatch_inbound(message: InboundMessage, decision: RouteDecision) -> str:
logger.info("dispatch 陆运核对卡确定:纠正闲聊路由 sender=%s", message.sender_id)
handle_text_inquiry(message)
return "ordinary_text_inquiry"
if decision.intent == "ordinary_text_other" and should_resume_other_as_inquiry(message):
logger.info("dispatch 补问续填:纠正闲聊路由 sender=%s", message.sender_id)
handle_text_inquiry(message)
return "ordinary_text_inquiry"
if decision.intent == "quote_adjust":
logger.info("dispatch 调价意图 sender=%s", message.sender_id)
handle_text_inquiry(message, prefer_quoted=True)
return "quote_adjust"
if decision.intent == "handoff_human":
logger.info("dispatch 转人工意图 sender=%s", message.sender_id)
handle_text_inquiry(message, prefer_handoff=True)
return "handoff_human"
if decision.intent == "continue_thread":
continue_thread.handle_continue_thread(message, thread_id=decision.thread_id)
return decision.intent
@@ -33,6 +33,7 @@ ACTION_INTENTS: dict[str, str] = {
"ORDINARY_TEXT_OTHER": "ordinary_text_other",
"CONTINUE_HISTORICAL_TICKET": "continue_thread",
"QUOTE_ADJUST": "quote_adjust",
"HANDOFF_HUMAN": "handoff_human",
}