_RATIONALE: dict[str, str] = { "ESCALATE": "needs a human agent immediately", "FOLLOW_UP": "requires follow-up from the support team", "LOG_FEEDBACK": "can be logged as positive feedback", "AUTO_RESOLVE": "can be auto-resolved with a helpful response", } def explain(sentiment: dict, signals: dict, decision: dict) -> str: dec = decision["decision"] label = sentiment["label"] conf = sentiment["confidence"] urgency = signals["urgency"] intent = signals["intent"] rationale = _RATIONALE.get(dec, "requires review") return ( f"Decision: {dec} — message is {label} (confidence {conf:.2f})" f" with {urgency} urgency and a {intent} intent," f" so it {rationale}." )