human hand off

This commit is contained in:
debu-2 2026-10-06 07:12:55 +05:30
parent d0fee5c8f7
commit 7af776196a
34 changed files with 2941 additions and 195 deletions

View file

@ -1,11 +1,13 @@
from bson import ObjectId
from app.services.handoff_mirror_policy import (
GENERATED_BY_AGENT,
GENERATED_BY_CUSTOMER,
GENERATED_BY_HANDOFF_BRIDGE,
GENERATED_BY_RELAY_ACK,
MESSAGE_ORIGIN_EXTERNAL_CUSTOMER,
MESSAGE_ORIGIN_HUMAN_OWNER,
MESSAGE_ORIGIN_AGENT,
is_relay_acknowledgment_message,
should_mirror_to_human,
)
@ -40,6 +42,27 @@ def test_should_not_mirror_human_origin():
assert should_mirror_to_human(message) is False
def test_should_mirror_agent_authored_external_reply():
message = {
"message_scope": "EXTERNAL",
"direction": "outbound",
"generated_by": GENERATED_BY_AGENT,
"message_origin": MESSAGE_ORIGIN_AGENT,
}
assert should_mirror_to_human(message) is True
def test_should_not_echo_human_relay_back_to_owner():
message = {
"message_scope": "EXTERNAL",
"direction": "outbound",
"generated_by": GENERATED_BY_HANDOFF_BRIDGE,
"message_origin": MESSAGE_ORIGIN_HUMAN_OWNER,
"generated_from_handoff_message_id": ObjectId(),
}
assert should_mirror_to_human(message) is False
def test_is_relay_acknowledgment_detects_legacy_body():
message = {
"direction": "outbound",