Your plugin can finally tell a wake-up from a reply

Half past two in the morning, your phone buzzes on the nightstand. You assume it is a colleague, and it is not: the background job you started yesterday finished, Hermes wrote itself a short summary, and your notification plugin dutifully delivered it. Earlier that day the same thing happened while you were sitting at the keyboard — same alert, while you were already reading the reply.
The plugin is not badly written. It simply had only one question available: did someone send input this turn? That answer cannot separate a person from one of Hermes’s own background producers, so alerts arrive when nobody is being spoken to, and stay silent about what actually needs you.
A turn has more than one kind of author
Two terms first. A turn is one round: Hermes receives some input, works, and produces a reply. A plugin hook is a callback a plugin attaches to that flow — after the model call, before the session ends, and so on.
Hermes wakes itself up all the time. You start a long command and it comes back to report. You open a sub-agent and its result has to re-enter the parent session. A watch matches, a liveness tick fires. Inside the gateway those turns travel the same path as a message someone typed, so a plugin sees an ordinary turn either way.
PR #160132 adds the missing question: hermes_cli.plugin_session.turn_origin(), and ctx.turn_origin() from plugin context. It answers in exactly two cases and stays silent for everything else.
turn_origin() returns |
When |
|---|---|
"process_notification" |
A background process’s notice: completion, watch match, watch disabled, or a liveness tick |
"delegation_result" |
An async delegation’s result re-entering its parent session |
None |
Every other turn — see the list below |
It names the producer of the turn’s input. It does not say whether a human is watching, and confusing those two questions is exactly what makes notification plugins noisy.
What it deliberately does not answer
None does not mean “unknown”. It means “Hermes did not start this one”. That covers more ground than people expect:
- A message typed in a client, whether or not that client announced itself;
- A message from a messaging chat, an API request, a Bot Chat delivery, or
hermes peer dm; - A restart resuming an interrupted turn, a goal continuation, cron, Kanban and other automation wakes;
- A message a plugin injected itself;
- A steer or interrupt text that runs as the next turn.
There is a follow-on rule worth knowing: once a person’s accepted steer or redirect joins the running turn, turn_origin() becomes None for the rest of that turn, because the reply now answers that person too. A refused steer changes nothing.
One more edge: inside a plugin’s own slash command no turn is running, so the answer is None there as well.
Using it: quiet the alerts Hermes sends itself
The direct use is to ask before you notify. This belongs in a turn hook such as post_llm_call or on_session_end:
def maybe_notify(ctx, text):
# Background completions and delegation results have their own delivery path.
if ctx.turn_origin() is not None:
return
# None can still be a client that announced nothing — not the same as a wake.
client = ctx.turn_client()
turn_client() is the older neighbour: it names the client that submitted the turn (for example {"name": "hermes-desktop", "kind": "desktop"}), but returns None both for a client that announced nothing and for a Hermes-started wake. Those two used to look identical from inside a plugin. turn_origin() is what separates them, and that is the most practical part of this change.
You can go one step further with ctx.session_viewers(), which lists the connections attached to the calling session right now — each with name, kind, idle_seconds, basis and can_alert. If the point of your notification is to pull a person back, “someone is here and typed twelve seconds ago” should not trigger a phone alert:
viewers = ctx.session_viewers()
someone_active = any(
(v.get("idle_seconds") or 10**9) < 60 and v.get("can_alert")
for v in viewers
)
if someone_active:
return
Two traps: hosted isolation, and labels are not permissions
The first trap is plugins.isolation: host. A hosted plugin runs in its own process, where there is no gateway and no current turn, so the module-level form answers None — always:
from hermes_cli import plugin_session
plugin_session.turn_origin() # always None in a hosted plugin
ctx.turn_origin() # asks the gateway, answers correctly
Use the ctx form anywhere the plugin might run hosted. That is also what the docs say outright: the module-level functions only answer inside the gateway process.
The second trap is treating the answer as authority. turn_origin() and turn_client() are labels describing how the turn arrived, not proof of identity. Do not skip an approval because the origin says process_notification, and do not gate anything on it. Values may also be added later, so handle the ones you know instead of collapsing everything non-None into “a human”.
Availability
It merged to main on November 25, 2026. v0.23.4 shipped on November 24, so the interface is not in that tag yet — it is a main-only addition. Probe with getattr rather than calling it blindly:
import hermes_cli.plugin_session as ps
if not hasattr(ps, "turn_origin"):
# Older build: fall back to turn_client() only
...
If you are building notifications, the companion change that hands you a prompt_id for an open question (so a phone tap can answer it) is covered in the plugin prompt hooks post. Plugin install and lifecycle live in the hermes plugins reference, and the wider window is on the v0.23.4 release page.
Update (2026-11-28): these changes shipped in v0.23.5 (November 28) —
hermes updatebrings them in. The “not in v0.23.4 / onmainonly” wording above is a snapshot from publication time.