Playbook
The live state graph, label set, and voice rules the engine actually loads — read fresh from disk/DB on every request, never a hand-maintained copy.
State graph, state × label matrix, interrupts
live from cs_policy.py · last modified 2026-08-14 19:55:09 UTC · no separate version-history tracking exists yet — this is the file's on-disk mtime.
"ESCALATE"
"EXECUTE_PROMISE"
"FULL_REFUND"
"OFFER_DISCOUNT_10_KEEP"
"OFFER_DISCOUNT_20_KEEP"
"OFFER_PRICE_MINUS_SHIPPING"
"OFFER_REPLACEMENT"
"REPLY_INFO"
200.0
[
[
"LEGAL_THREAT",
"<function _interrupt_legal_threat at 0x7889678278a0>"
],
[
"THREATENS_CHARGEBACK",
"<function _interrupt_chargeback at 0x788966f44a90>"
]
]5
2
3
{
"0": "NEW",
"1": "REPLACEMENT_OFFERED",
"2": "KEEP_10_OFFERED",
"3": "KEEP_20_OFFERED",
"4": "PRICE_MINUS_SHIPPING_OFFERED",
"5": "FULL_REFUND_OFFERED"
}0
4
1
"_Feature((3, 7, 0, 'beta', 1), None, 16777216)"
- dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False)
- decide(case: 'dict', label: 'str', vars_: 'dict') -> 'Decision'
- field(*, default=<dataclasses._MISSING_TYPE object at 0x788969538d70>, default_factory=<dataclasses._MISSING_TYPE object at 0x788969538d70>, init=True, repr=True, hash=None, compare=True, metadata=None, kw_only=<dataclasses._MISSING_TYPE object at 0x788969538d70>, doc=None)
Label set (17 active, live from cs_labels)
| Label | Description | Real example |
|---|---|---|
| ACCEPTS_OFFER | Customer agrees to the offer/resolution proposed | no example logged yet |
| ADDRESS_CHANGE | Customer requests a shipping address change | no example logged yet |
| ASKS_REFUND | Customer explicitly requests a refund | no example logged yet |
| ASKS_REPLACEMENT | Customer explicitly requests a replacement item | no example logged yet |
| AUTHENTICITY_DOUBT | Customer questions whether the product is authentic/genuine | no example logged yet |
| CANCEL_REQUEST | Customer requests order cancellation | no example logged yet |
| DAMAGED | Item arrived damaged or defective | no example logged yet |
| LEGAL_THREAT | Customer threatens legal action or invokes a regulator/lawyer | no example logged yet |
| NOT_ARRIVED | Order has not arrived (lost/delayed, customer reporting non-receipt) | no example logged yet |
| OFF_SCRIPT | Message doesn't fit any other label / needs human judgement | no example logged yet |
| PRODUCT_QUESTION | General question about a product's features/materials | no example logged yet |
| REFUSES_OFFER | Customer rejects the offer/resolution proposed | no example logged yet |
| SIZING_QUESTION | Pre-purchase or general sizing/fit question | no example logged yet |
| THREATENS_CHARGEBACK | Customer threatens or mentions a chargeback/dispute | no example logged yet |
| WHERE_IS_ORDER | Customer asking for order/shipping status (WISMO) | no example logged yet |
| WRONG_ITEM | Customer received the wrong item entirely | no example logged yet |
| WRONG_SIZE | Customer received the wrong size | no example logged yet |
Label spec (engine-side)
live from cs_labels_spec.py · last modified 2026-08-14 19:55:07 UTC · no separate version-history tracking exists yet — this is the file's on-disk mtime.
[ "LEGAL_THREAT", "THREATENS_CHARGEBACK" ]
[ "ACCEPTS_OFFER", "ADDRESS_CHANGE", "ASKS_REFUND", "ASKS_REPLACEMENT", "AUTHENTICITY_DOUBT", "CANCEL_REQUEST", "DAMAGED", "LEGAL_THREAT", "NOT_ARRIVED", "OFF_SCRIPT", "PRODUCT_QUESTION", "REFUSES_OFFER", "SIZING_QUESTION", "THREATENS_CHARGEBACK", "WHERE_IS_ORDER", "WRONG_ITEM", "WRONG_SIZE" ]
{
"ACCEPTS_OFFER": {
"description": "Customer agrees to the offer/resolution proposed",
"example": "Customer replies 'ok that works, thank you' to a settlement we already offered."
},
"ADDRESS_CHANGE": {
"description": "Customer requests a shipping address change",
"example": "'Can you ship to my new address instead, I moved.'"
},
"ASKS_REFUND": {
"description": "Customer explicitly requests a refund",
"example": "'I'd like a refund please, I changed my mind.' No claim of a defect."
},
"ASKS_REPLACEMENT": {
"description": "Customer explicitly requests a replacement item",
"example": "'Can you send me a replacement in a different colour.'"
},
"AUTHENTICITY_DOUBT": {
"description": "Customer questions whether the product is authentic/genuine",
"example": "'Is this a real Longchamp bag? It doesn't look right.'"
},
"CANCEL_REQUEST": {
"description": "Customer requests order cancellation",
"example": "'Please cancel my order, I don't want it anymore.'"
},
"DAMAGED": {
"description": "Item arrived damaged or defective",
"example": "'The item arrived with a broken zip / stain / tear.'"
},
"LEGAL_THREAT": {
"description": "Customer threatens legal action or invokes a regulator/lawyer",
"example": "'I will be reporting this to Trading Standards / my solicitor.'"
},
"NOT_ARRIVED": {
"description": "Order has not arrived (lost/delayed, customer reporting non-receipt)",
"example": "'It's been 3 weeks and nothing has shown up.'"
},
"OFF_SCRIPT": {
"description": "Message doesn't fit any other label / needs human judgement",
"example": "Anything ambiguous, multi-topic in a way that defeats one label, or clearly unusual."
},
"PRODUCT_QUESTION": {
"description": "General question about a product's features/materials",
"example": "'What fabric is this made of? Is it machine washable?'"
},
"REFUSES_OFFER": {
"description": "Customer rejects the offer/resolution proposed",
"example": "'No, that's not good enough, I want my money back.' to an offer we already made."
},
"SIZING_QUESTION": {
"description": "Pre-purchase or general sizing/fit question",
"example": "'Does this run small? Should I size up?'"
},
"THREATENS_CHARGEBACK": {
"description": "Customer threatens or mentions a chargeback/dispute",
"example": "'Refund me now or I'm opening a chargeback with my bank.'"
},
"WHERE_IS_ORDER": {
"description": "Customer asking for order/shipping status (WISMO)",
"example": "'Where is my order? Any tracking update?'"
},
"WRONG_ITEM": {
"description": "Customer received the wrong item entirely",
"example": "'I ordered the blue jacket but received a black skirt.'"
},
"WRONG_SIZE": {
"description": "Customer received the wrong size",
"example": "'I ordered a Medium but got a Small.'"
}
}"frozenset({'WRONG_SIZE', 'ASKS_REFUND', 'LEGAL_THREAT', 'SIZING_QUESTION', 'WRONG_ITEM', 'ADDRESS_CHANGE', 'OFF_SCRIPT', 'ASKS_REPLACEMENT', 'PRODUCT_QUESTION', 'REFUSES_OFFER', 'AUTHENTICITY_DOUBT', 'WHERE_IS_ORDER', 'NOT_ARRIVED', 'CANCEL_REQUEST', 'ACCEPTS_OFFER', 'DAMAGED', 'THREATENS_CHARGEBACK'})""_Feature((3, 7, 0, 'beta', 1), None, 16777216)"
- is_valid(label: 'str') -> 'bool'
- sync_check(db_rows: 'list[str]') -> 'list[str]'
Voice rules
live from cs_voice.py · last modified 2026-08-14 20:00:43 UTC · no separate version-history tracking exists yet — this is the file's on-disk mtime.
{
"REPLY_INFO": "Answer their question directly using the facts given.",
"OFFER_REPLACEMENT": "Offer to send a replacement in the correct size/item, free of charge.",
"OFFER_DISCOUNT_10_KEEP": "Offer the exact percentage off given in FACTS ('offer_percentage') as a thank-you for keeping the item, instead of a return. Use that number exactly — never a different percentage, never a cash figure.",
"OFFER_DISCOUNT_20_KEEP": "Offer the exact percentage off given in FACTS ('offer_percentage') for keeping the item, instead of a return. Use that number exactly — never a different percentage, never a cash figure.",
"OFFER_PRICE_MINUS_SHIPPING": "Offer to settle for the exact amount given in FACTS ('settlement_amount') — the order value minus return shipping — customer keeps the item, nothing to send back. Use that figure exactly, never a different number.",
"FULL_REFUND": "Confirm a full refund to the original payment method. If FACTS gives a 'settlement_amount', you may cite it; otherwise just confirm the refund without stating a figure you weren't given.",
"EXECUTE_PROMISE": "Follow through on the commitment already made to this customer, exactly as described in FACTS — do not alter the figure or the remedy.",
"ESCALATE": "Acknowledge the message warmly and let them know a member of the team is personally looking into it — do not promise a timeline or outcome, and do not state any figure at all."
}"Write a complete, ready-to-send email reply: a brief greeting using the customer's name if given, the body, and a sign-off with the given signature. No subject line (the thread already has one). Plain text only."
[ "Never use an em dash or en dash (replace with a comma, period, or 'and').", "Never offer a return address or a shipping label of any kind.", "Never charge, mention, or imply a shipping fee, restocking fee, or \"small contribution\" for a return, exchange, or replacement — it is always free to the customer.", "Never claim we have contacted, heard from, or are checking with the manufacturer/supplier/warehouse/courier unless that is explicitly true in the facts you were given.", "Never cite a consumer-protection statute, regulation, clause number, or any specific law.", "Never call our own listing, product, or the way we sell it unlawful, mis-sold, counterfeit, or fake — even defensively.", "Never say a parcel 'has shipped' or is 'on its way' unless the tracking facts you were given show a carrier checkpoint past 'information received'/'label created'.", "Never state a cash amount in a cashback/keep-the-item offer — percentages only (e.g. 'a percentage off' or 'X%'), never a converted currency figure.", "Never promise to 'chase', 'follow up with', 'investigate', 'escalate to management', 'look into it', or 'come back to you' about something you are not immediately resolving in this reply — state plainly what you can and cannot do right now instead.", "Never say a refund, cashback, or replacement 'has been issued/sent/processed/arranged' unless the facts you were given say it was actually executed — an offer that hasn't been accepted and executed is an offer, not a done deal.", "Never use markdown, asterisks, bullet characters, or code formatting — plain prose only, this is an email.", "Never open with 'Hi there' if a customer name is given in the facts — use their name." ]
"You are writing as the customer support voice for the store. Warm, direct, human — never corporate-sounding, never robotic, never over-apologetic filler. Short paragraphs. Address the customer's actual question or complaint first, in plain language, before anything else. Sign off with the signature name and role you're given in the facts."
"_Feature((3, 7, 0, 'beta', 1), None, 16777216)"
- build_system_prompt(*, language: 'str' = 'English', signature: 'str' = 'Support', extra_persona: 'str' = '') -> 'str'
- build_user_prompt(*, customer_email: 'str', facts: 'dict', action: 'str', amount: 'float | None' = None, currency: 'str | None' = None) -> 'str'