From 223f846782bd169f61ddd4e0c347b1978fa5d7f5 Mon Sep 17 00:00:00 2001 From: debu-2 Date: Tue, 6 Oct 2026 08:04:24 +0530 Subject: [PATCH] human hand off fix reputation --- backend/app/services/human_handoff_service.py | 5 ++--- backend/tests/test_human_handoff_service.py | 13 ++++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/backend/app/services/human_handoff_service.py b/backend/app/services/human_handoff_service.py index fd4e61f..795516e 100644 --- a/backend/app/services/human_handoff_service.py +++ b/backend/app/services/human_handoff_service.py @@ -724,10 +724,9 @@ async def process_human_reply( def _mirror_from_identity( source: dict, agent_name: str, agent_email: str ) -> tuple[str, str]: + # Always send From the Gentic mailbox so SPF/DKIM/DMARC stay aligned. if source.get("direction") == "inbound": - sender = source.get("sender") or {} - address = (sender.get("address") or "").strip() - return sender_display_name(sender), address or agent_email + return sender_display_name(source.get("sender") or {}), agent_email return agent_name, agent_email diff --git a/backend/tests/test_human_handoff_service.py b/backend/tests/test_human_handoff_service.py index 11342e6..489af8f 100644 --- a/backend/tests/test_human_handoff_service.py +++ b/backend/tests/test_human_handoff_service.py @@ -72,21 +72,21 @@ def test_quote_trail_is_detected_in_forwarded_history(): assert _body_has_quote_trail("sender: E", None) is False -def test_mirror_from_uses_one_address_not_both(): +def test_mirror_from_stays_on_gentic_address(): name, address = _mirror_from_identity( { "direction": "inbound", "sender": { - "name": "Suyash Dixit", - "address": "suyashdixit091@gmail.com", + "name": "Parth Dixit", + "address": "parthdixit091@gmail.com", }, }, "Suyash Dixit", "suyash@gentic.email", ) - assert name == "Suyash Dixit" - assert address == "suyashdixit091@gmail.com" - assert "gentic.email" not in address + assert name == "Parth Dixit" + assert address == "suyash@gentic.email" + assert "gmail.com" not in address agent_name, agent_address = _mirror_from_identity( {"direction": "outbound", "sender": {"address": "suyash@gentic.email"}}, @@ -95,7 +95,6 @@ def test_mirror_from_uses_one_address_not_both(): ) assert agent_name == "Suyash Dixit" assert agent_address == "suyash@gentic.email" - assert "gmail.com" not in agent_address def test_private_subject_contains_customer_name_and_external_subject():