feat: require complete KB-grounded answers (no dropped facts) + ask did-that-answer-your-question after each answer, per ai-operator spec
deploy / deploy (push) Failing after 4s

This commit is contained in:
a.arystanbek
2026-08-30 21:22:54 +00:00
parent 78dfe6a9e1
commit c261d08036
@@ -135,8 +135,12 @@ def human_fallback_reply(language: str, *, is_greeting: bool = False) -> str:
def operator_system_prompt(*, language: str, channel_label: str, is_voice: bool, config: Any | None = None) -> str:
preferred_language = "Kazakh" if str(language or "").strip().lower() == "kz" else "Russian"
delivery_hint = (
"The reply will be spoken aloud over a phone call, so keep it concise, natural, and easy to listen to. "
"Prefer one or two short sentences and at most one clarifying question. "
"The reply will be spoken aloud over a phone call, so keep it concise, natural, and easy to listen to, "
"but never at the cost of dropping a required fact. "
"Use as many short sentences as needed to cover every material fact from the grounding kb_results "
"snippet completely - required steps, codes, commands, deadlines, amounts, and conditions - typically "
"two to four short sentences; never silently omit or shorten out a required step just to sound brief. "
"At most one clarifying question per turn. "
"The text-to-speech engine reads exactly what you write, digit by digit, with no number formatting of its own, "
"so never output bare digits for phone numbers, hotline numbers, or dates — always spell them out in words "
"the way a person would actually say them aloud in natural spoken Russian/Kazakh. "
@@ -174,6 +178,8 @@ def operator_system_prompt(*, language: str, channel_label: str, is_voice: bool,
"Paraphrase them naturally instead of quoting them verbatim. "
"Never invent order statuses, tariffs, discounts, deadlines, addresses, availability, approvals, or actions "
"that are not supported by context. If the available facts are insufficient, ask one short clarifying question. "
"After you deliver a complete answer grounded in kb_results (not when you are asking a clarifying question, "
"handling an identity/off-topic reply, or closing the call), end reply_text with a brief natural check such as «Ответила ли я на ваш вопрос?» in Russian, or its natural Kazakh equivalent, phrased differently each time so it does not sound scripted. "
"If the customer explicitly asks for a live operator, if the request is sensitive, or if the case is blocked, "
"set needs_handoff=true. "
f"{delivery_hint} "