Skip to content
Closed
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
9 changes: 9 additions & 0 deletions agent/prompt_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ def _strip_yaml_frontmatter(content: str) -> str:
"Skills that aren't maintained become liabilities."
)

SILENT_RESPONSE_GUIDANCE = (
"If you have nothing meaningful to add in a conversation, you can suppress delivery "
"by responding with the exact string '[SILENT]'. This must be the ONLY content "
"of your response; any additional characters, whitespace, emojis, or commentary "
"will cause the message to leak and be delivered to the user. The transcript entry "
"is preserved for continuity. This works for the gateway's final_response "
"delivery path β€” direct send_message tool calls are not affected."
)

KANBAN_GUIDANCE = (
"# Kanban task execution protocol\n"
"You have been assigned ONE task from "
Expand Down
4 changes: 4 additions & 0 deletions agent/system_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
OPENAI_MODEL_EXECUTION_GUIDANCE,
PLATFORM_HINTS,
SESSION_SEARCH_GUIDANCE,
SILENT_RESPONSE_GUIDANCE,
SKILLS_GUIDANCE,
STEER_CHANNEL_NOTE,
TASK_COMPLETION_GUIDANCE,
Expand Down Expand Up @@ -102,6 +103,9 @@ def build_system_prompt_parts(agent: Any, system_message: Optional[str] = None)
# Pointer to the hermes-agent skill + docs for user questions about Hermes itself.
stable_parts.append(HERMES_AGENT_HELP_GUIDANCE)

# [SILENT] response marker β€” always available, regardless of tools/platform.
stable_parts.append(SILENT_RESPONSE_GUIDANCE)

# Universal task-completion / no-fabrication guidance. Applied to ALL
# models regardless of tool_use_enforcement gating β€” the failure modes
# this targets (stopping after a stub; fabricating output when a real
Expand Down
15 changes: 15 additions & 0 deletions gateway/platforms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@

logger = logging.getLogger(__name__)

# Sentinel: when the agent's response is exactly this marker, delivery is
# suppressed. The agent can use this to opt out of replying (e.g. in group
# channels when there's nothing meaningful to add). Output is still persisted
# in the transcript for continuity.
SILENT_MARKER = "[SILENT]"

# Audio file extensions Hermes recognizes for native audio delivery.
# Kept in sync with tools/send_message_tool.py and cron/scheduler.py via
# should_send_media_as_audio() below.
Expand Down Expand Up @@ -4094,6 +4100,15 @@ async def _stop_typing_task() -> None:
# post-send block can schedule the deletion.
response, _ephemeral_ttl = self._unwrap_ephemeral(response)

# [SILENT] marker: agent opted out of replying. Suppress delivery
# but keep the transcript entry for continuity.
if response and response.strip() == SILENT_MARKER:
logger.info(
"[%s] Agent returned %s β€” suppressing delivery for %s",
self.name, SILENT_MARKER, event.source.chat_id,
)
response = None

# Send response if any. A None/empty response is normal when
# streaming already delivered the text (already_sent=True) or
# when the message was queued behind an active agent. Log at
Expand Down
28 changes: 19 additions & 9 deletions gateway/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,7 @@ def _reload_runtime_env_preserving_config_authority() -> None:
EphemeralReply,
MessageEvent,
MessageType,
SILENT_MARKER,
_reply_anchor_for_event,
merge_pending_message_event,
)
Expand Down Expand Up @@ -14883,18 +14884,27 @@ async def _notify_long_running():
)
first_response = result.get("final_response", "")
if first_response and not _already_streamed:
try:
# Skip resend if the response is [SILENT] β€” it was
# intentionally suppressed and shouldn't leak here.
if first_response.strip() == SILENT_MARKER:
logger.info(
"Queued follow-up for session %s: final stream delivery not confirmed; sending first response before continuing.",
"Queued follow-up for session %s: first response is %s, skipping resend.",
session_key or "?",
SILENT_MARKER,
)
await adapter.send(
source.chat_id,
first_response,
metadata=_status_thread_metadata,
)
except Exception as e:
logger.warning("Failed to send first response before queued message: %s", e)
else:
try:
logger.info(
"Queued follow-up for session %s: final stream delivery not confirmed; sending first response before continuing.",
session_key or "?",
)
await adapter.send(
source.chat_id,
first_response,
metadata=_status_thread_metadata,
)
except Exception as e:
logger.warning("Failed to send first response before queued message: %s", e)
elif first_response:
logger.info(
"Queued follow-up for session %s: skipping resend because final streamed delivery was confirmed.",
Expand Down
1 change: 1 addition & 0 deletions hermes_cli/tips.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
"Voice messages on Telegram, Discord, WhatsApp, and Slack are auto-transcribed.",

# --- Gateway & Messaging ---
"If the agent's response is exactly [SILENT], delivery is suppressed β€” useful in group channels when there's nothing to add.",
"Hermes runs on 21 messaging platforms: Telegram, Discord, Slack, WhatsApp, Signal, Matrix, IRC, Microsoft Teams, email, and more.",
"hermes gateway install sets it up as a system service that starts on boot.",
"DingTalk uses Stream Mode β€” no webhooks or public URL needed.",
Expand Down