Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,10 @@ def register(ctx):
```

Successful delivery arms a one-turn marker for the current Hermes session.
`transform_media_delivery_output` consumes it and returns Hermes' canonical
`NO_REPLY` response before the gateway sees the final text. Failed delivery does
`transform_media_delivery_output` consumes it and replaces the final text with
`MEDIA_DELIVERED_REPLY` (a single ✅) before the gateway sees it. It does not
return `NO_REPLY`: Hermes v0.22+ rejects a silence marker on a turn that expects
a reply and sends the user a warning instead. Failed delivery does
not arm suppression, and `on_session_end` clears any unconsumed marker. These are
Hermes-agent lifecycle and response contracts; they are not OpenClaw shapes.

Expand Down
13 changes: 10 additions & 3 deletions hermes_plugin_kit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def register(ctx):
"SessionDBCompatibilityError",
"deliver_media",
"resolve_delivery_target",
"MEDIA_DELIVERED_REPLY",
"transform_media_delivery_output",
"clear_media_delivery_state",
"MediaType",
Expand Down Expand Up @@ -1870,6 +1871,10 @@ def _mark_media_delivery_success(context: dict[str, Any]) -> None:
)


# The turn's visible reply after the attachment itself was already sent.
MEDIA_DELIVERED_REPLY = "✅"


def transform_media_delivery_output(
response_text: str = "",
session_id: str = "",
Expand All @@ -1879,8 +1884,10 @@ def transform_media_delivery_output(

A successful :func:`deliver_media` call arms one task-local suppression.
The finalizer then replaces any model-authored text or repeated ``MEDIA``
tag with Hermes' canonical ``NO_REPLY`` marker. State is consumed once, so
later turns in the same session are unaffected.
tag with :data:`MEDIA_DELIVERED_REPLY`. Not ``NO_REPLY``: Hermes v0.22+
rejects a silence marker on a turn that expects a reply and sends a
warning instead. State is consumed once, so later turns in the same
session are unaffected.
"""
context_id = str(session_id or "").strip()
if not context_id:
Expand All @@ -1895,7 +1902,7 @@ def transform_media_delivery_output(
"event=media_final_response_suppressed original_chars=%d",
len(str(response_text or "")),
)
return "NO_REPLY"
return MEDIA_DELIVERED_REPLY


def clear_media_delivery_state(
Expand Down
7 changes: 7 additions & 0 deletions tests/test_hermes_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,13 @@ def test_lifecycle_calls_bind_to_real_plugincontext_signatures(self) -> None:
for method in ("launch", "status", "wait", "cancel", "result", "reconnect"):
self.assertTrue(callable(getattr(service, method)))

def test_media_delivered_reply_is_not_a_hermes_silence_marker(self) -> None:
"""Hermes v0.22+ replaces a silence marker on a user turn with a warning."""
from gateway.response_filters import is_intentional_silence_response # type: ignore

self.assertTrue(is_intentional_silence_response("NO_REPLY"))
self.assertFalse(is_intentional_silence_response(hpk.MEDIA_DELIVERED_REPLY))

def test_reserved_tool_names_match_the_host(self) -> None:
"""The kit's offline fallback must equal what the deployed Hermes intercepts."""
from model_tools import _AGENT_LOOP_TOOLS, _LEGACY_TOOL_ALIASES # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion tests/test_kit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ def test_successful_delivery_suppresses_the_same_turn_final_response_once(self)
session_id="session-1",
platform="telegram",
),
"NO_REPLY",
"✅",
)
self.assertIsNone(
hpk.transform_media_delivery_output(
Expand Down
Loading