Skip to content

feat(media): let an origin attachment be the turn's reply (as_reply) - #54

Merged
offendingcommit merged 1 commit into
mainfrom
fix/media-is-the-reply
Nov 19, 2026
Merged

offendingcommit merged 1 commit into
mainfrom
fix/media-is-the-reply

Conversation

@offendingcommit

Copy link
Copy Markdown
Owner

Problem

After a successful deliver_media, transform_media_delivery_output replaces the turn's final reply with a lone ✅ (#43). Hermes refuses a bare NO_REPLY on a turn that expects a reply. On Telegram the ✅ arrives as a second message after every voice memo or image, and it reads as a reaction.

Change

  • deliver_media(..., as_reply=True) to the origin target sends nothing at tool time. It returns deferred=True, host_result={"deferred": "final_reply"}.
  • transform_media_delivery_output makes the attachment the final reply: the model's own words, minus silence markers, copied [Sent …] notes and repeated MEDIA: lines, then the MEDIA: directive. A NO_REPLY turn sends the attachment alone. Several as_reply calls in one turn all ride the reply, in order.
  • Fallback: clear_media_delivery_state (Hermes fires on_session_end after every turn) sends any deferred attachment the reply did not carry directly. That covers failed, interrupted and empty turns, another transform winning, and a session id rotated by compression. It is keyed on both session_id and task_id.
  • Opt-in, because success now means "accepted", not "sent". sirens' video lane writes a confirmed-send receipt and must keep the direct send. Explicit targets and spoiler media always send directly; existing callers are unchanged.
  • README, AGENTS.md, and the research note docs/research/2026-11-19-telegram-checkmark-after-media.md.

Proof

  • mise run test: 338 tests OK (28 skipped, host-only).
  • mise run test-contract-pinned: receipt pinned bf0203a…; executed=28. Two new contract tests:
    • test_deferred_media_reply_is_delivered_as_a_voice_note_alone runs the reply through Hermes' own BasePlatformAdapter.extract_media and gets one voice attachment with empty text.
    • test_kit_silence_markers_match_the_host pins the kit's marker set to LIVE_GATEWAY_SILENT_MARKERS. It caught the host's four Chinese markers on the first run.
  • Falsifiers:
    • Disabling deferral (False and as_reply) fails 5 of the new tests.
    • Removing the turn-end send fails test_turn_end_sends_deferred_media_the_reply_never_carried.
  • Existing fix(media): end a delivered-media turn with a visible reply, not NO_REPLY #43/feat(media): strip copied sent-media history notes from final replies #46 tests are unchanged and still pass.

Not done yet

  • Opt in from persona-voice (voice memos) and sirens (voice and images, not video), and bump their kit pins.
  • Promote through offendingcommit/infra.
  • Live check: one Telegram voice memo on hermes-private. Expect exactly one voice note and no ✅, and a log showing media_delivery_deferred then media_reply_attached.

The deployed Hermes is 2bd378ed. The kit's contract pin is bf0203a. I read the deployed source in the pod for the paths this relies on, but the contract suite did not run against 2bd378ed.

https://claude.ai/code/session_01B6XeAXSoBKaEUbBRt5xcfB

After a successful deliver_media, the final reply is replaced with a lone
"✅" because Hermes refuses a bare NO_REPLY on a turn that expects a reply.
On Telegram that ✅ arrives as a second message and reads as a reaction.

deliver_media(..., as_reply=True) to the origin target now sends nothing at
tool time. transform_media_delivery_output makes the attachment the final
reply: the model's own words (minus silence markers, copied send notes and
repeated MEDIA lines) followed by the MEDIA directive, so a NO_REPLY turn
sends the voice note alone. Hermes delivers a MEDIA-only reply as one
attachment with no text (BasePlatformAdapter._extract_response_content).

If the reply never carries it (failed, interrupted or empty turn, or another
transform won), clear_media_delivery_state, which Hermes fires after every
turn, sends it directly, so a deferred attachment is never lost.

Opt-in because success now means "accepted", not "sent": sirens' video lane
records a confirmed-send receipt and must keep the direct send. Explicit
targets and spoiler media always send directly; existing callers are
unchanged.

Claude-Session: https://claude.ai/code/session_01B6XeAXSoBKaEUbBRt5xcfB
@offendingcommit
offendingcommit marked this pull request as ready for review November 19, 2026 17:09
@offendingcommit
offendingcommit merged commit 23ac709 into main Nov 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant