hermes-agent/tests/gateway/relay
Ben Barclay d26983e485
fix(gateway): relay TTS attachments + semantic auto-thread rename on the title turn (#74482)
Two relay-lane bugs from live Discord staging testing (2026-07-29):

1. TTS audio never attached over relay (any platform, any lane).
   _history_media_paths_for_session excluded only the trailing assistant
   entry from the persisted transcript when building the delivered-media
   dedup set. The agent persists rows as it produces them, so THIS turn's
   text_to_speech tool result (media_tag JSON) was already in the
   transcript at delivery time — the fresh TTS path deduped against
   itself and extract_media's attachment was silently stripped
   (response_delivery_dropped for a MEDIA-tag-only reply; fly logs show
   the exact signature). Fix: exclude everything from the last USER
   message onward (the current turn); prior-turn dedup unchanged.
   Affects every platform adapter (native + relay) on the non-streaming
   delivery path — the streaming path passes explicit history and was
   unaffected.

2. Connector-auto-created threads never got the LLM session-title
   rename. The title fires on the FIRST exchange, whose source is the
   PARENT channel event — the thread didn't exist at ingest, so the
   Phase 4 auto-thread markers can't be present and
   _is_discord_auto_thread_lane never matches on the relay title turn
   (initial titles worked; semantic renames never happened; staging
   telemetry shows zero thread_rename ops ever sent). Fix: consume the
   connector's new send-result feedback (paired gateway-gateway PR —
   contract §SendResult thread_id/auto_thread_name, additive):
   RelayAdapter.send() caches (thread_id, initial_name) per chat
   (bounded 256), run.py's title-callback registration + rename lane
   read it back and pass initial_name as only_if_current_name so the
   human-rename-wins guard holds on the relay lane too. Native marker
   path unchanged; connectors that don't stamp the fields degrade to
   exactly the old behavior.

Tests: 3 new (send-result feedback capture, absence, bound) in
test_relay_threads.py; 3 new in test_history_media_current_turn.py
(current-turn TTS not deduped, prior-turn still deduped, no-user-row
fallback). Relay suite 144 passed.
2026-07-29 18:00:18 -07:00
..
__init__.py
stub_connector.py feat(relay): Phase 3 interactive — native prompt UX (approvals/confirms/clarify) + react ack lifecycle (#71404) 2026-07-26 07:57:39 +10:00
test_auth.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_channel_context_consume.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_contract_doc_conformance.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_descriptor.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_descriptor_from_entry.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_handoff_relay_aliasing.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_identity_token_resolver.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_no_stub_leak.py test(relay): assert connector stub never leaks into production paths 2026-06-17 16:37:45 -07:00
test_relay_adapter.py test: prune low-value tests suite-wide (wave 1) — 46,820 → 28,106 test functions 2026-07-29 13:10:23 -07:00
test_relay_follow_up.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_relay_going_idle.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_relay_interactive.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_relay_interrupt.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_relay_media.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_relay_multiplatform.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_relay_passthrough.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_relay_per_platform_caps.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_relay_policy_send.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_relay_registration.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_relay_roundtrip.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_relay_roundtrip_telegram.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_relay_sheds_crypto.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_relay_slack_dm_streaming.py fix(relay): coerce Slack behavior flags exactly as the native adapter does 2026-07-29 12:03:01 -07:00
test_relay_slack_prompt_dm_root.py docs(relay): finish the QA-N scrub in the new relay test files 2026-07-29 12:03:01 -07:00
test_relay_threads.py fix(gateway): relay TTS attachments + semantic auto-thread rename on the title turn (#74482) 2026-07-29 18:00:18 -07:00
test_self_provision.py test: prune low-value tests suite-wide (wave 1) — 46,820 → 28,106 test functions 2026-07-29 13:10:23 -07:00
test_wire_user_identity.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00
test_ws_transport.py test: prune wave 2 + speed fixes — 28,106 → 19,757 test functions, suite wall 315s → 294s 2026-07-29 13:39:40 -07:00