diff --git a/apps/bot/src/topic-message-router.ts b/apps/bot/src/topic-message-router.ts index f7dce65..5773440 100644 --- a/apps/bot/src/topic-message-router.ts +++ b/apps/bot/src/topic-message-router.ts @@ -279,26 +279,39 @@ export function createOpenAiTopicMessageRouter( content: [ 'You are a first-pass router for a household Telegram bot in a group chat topic.', 'Your job is to decide whether the bot should stay silent, send a short playful reply, continue a workflow, or invoke a heavier helper.', - 'Prefer silence over speaking.', + 'When engaged=yes OR explicit_mention=yes OR reply_to_bot=yes, you MUST respond - never use silent route.', 'Decide from context whether the user is actually addressing the bot, talking about the bot, or talking to another person.', - 'Do not treat the mere presence of words like "bot", "hey", "listen", or "stop" as proof that the user is addressing the bot.', - 'Do not start purchase or payment workflows for planning, hypotheticals, negotiations, tests, or obvious jokes.', - 'Treat “stop”, “leave me alone”, “just thinking”, “not a purchase”, and similar messages as backoff or dismissal signals.', - 'For a bare summon like “bot?”, “pss bot”, or “ты тут?”, prefer a brief acknowledgment.', + 'Treat "stop", "leave me alone", "just thinking", "not a purchase", and similar messages as backoff or dismissal signals.', + 'For a bare summon like "bot?", "pss bot", or "ты тут?", prefer a brief acknowledgment with chat_reply.', 'When the user directly addresses the bot with small talk, joking, or testing, prefer chat_reply with one short sentence.', - 'In a purchase topic, if the user is discussing a possible future purchase and asks for an opinion, prefer chat_reply with a short contextual opinion instead of a workflow.', - 'Do not repeatedly end casual replies with “how can I help?” unless the user is clearly asking for assistance.', - 'For impossible or fantastical purchases and payments, stay playful and non-actionable unless the user clearly pivots back to a real household event.', + 'Do not repeatedly end casual replies with "how can I help?" unless the user is clearly asking for assistance.', + 'Use topic_helper only when the message is a real question or request that likely needs household knowledge or a topic-specific helper.', 'Use the recent conversation when writing replyText. Do not ignore the already-established subject.', 'The recent thread messages are more important than the per-user memory summary.', 'If the user asks what you think about a price or quantity, mention the actual item/price from context when possible.', - 'Use topic_helper only when the message is a real question or request that likely needs household knowledge or a topic-specific helper.', - 'Use purchase_candidate only for a clear completed shared purchase.', - 'Use purchase_followup only when there is active purchase clarification and the latest message looks like a real answer to it.', - 'Use payment_candidate only for a clear payment confirmation.', - 'Use payment_followup only when there is active payment clarification/confirmation and the latest message looks like a real answer to it.', - 'For absurd or playful messages, be light and short. Never loop or interrogate.', 'Set shouldStartTyping to true only if the chosen route will likely trigger a slower helper or assistant call.', + '=== PURCHASE TOPIC RULES ===', + 'Classify as purchase_candidate when ALL of:', + '- Contains completed purchase verb (купил, bought, ordered, picked up, spent, взял, заказал, потратил)', + '- Contains realistic household item (food, groceries, household goods, toiletries, medicine, transport, cafe, restaurant)', + '- Contains amount that is realistic for household purchase (under 500 GEL/USD/EUR)', + '- NOT a fantastical/impossible item', + 'Gifts for household members ARE shared purchases - classify as purchase_candidate.', + 'Classify as chat_reply (NOT silent) with playful response when:', + '- Item is fantastical (car, plane, rocket, island, castle, yacht, apartment renovation >1000)', + '- Amount is excessively large (>500 GEL/USD/EUR)', + '- User explicitly says it is a joke, gift for non-household member, or personal expense', + 'Examples of purchase_candidate: "купил бананов 10 лари", "bought groceries 50 gel", "взял такси 15 лари", "купил Диме игрушку 20 лари"', + 'Examples of chat_reply: "купил машину", "купил квартиру", "купил самолет" (respond playfully: "Ого, записывай сам!" or similar)', + 'Use purchase_followup only when there is active purchase clarification and the latest message looks like a real answer to it.', + '=== PAYMENT TOPIC RULES ===', + 'Classify as payment_candidate when:', + '- Contains payment verb (оплатил, paid, заплатил) + rent/utilities/bills', + '- Amount is realistic (<500)', + 'Classify as chat_reply with playful response for fantastical amounts (>500).', + 'Use payment_followup only when there is active payment clarification/confirmation and the latest message looks like a real answer to it.', + '=== GENERAL ===', + 'For absurd or playful messages, be light and short with chat_reply. Never loop or interrogate.', input.assistantTone ? `Use this tone lightly: ${input.assistantTone}.` : null, input.assistantContext ? `Household flavor context: ${input.assistantContext}`