Skip to content

The agent that grows with you

fix(gateway): pin the remaining persistence-failure commands to the failing profile

kshitijk4poor9c093c83e431
diff --git a/agent/turn_explainers.py b/agent/turn_explainers.py
index 0c17293d7a6..eadc4935409 100644
--- a/agent/turn_explainers.py
+++ b/agent/turn_explainers.py
@@ -118,16 +118,15 @@ _PERSISTENCE_CAUSE_EXPLANATIONS: Dict[str, str] = {
"the session database file was replaced while Hermes was running, so this "
"message was not saved (a copy is kept in {home}/sessions/). Stop Hermes "
"(`hermes {profile_arg}gateway stop`), run `hermes {profile_arg}doctor` — not "
- "`hermes {profile_arg}doctor --fix`, which "
- "would repair the wrong file in place — then start it again and send your message "
- "once more. Advanced recovery steps are in the log."
+ "`hermes {profile_arg}doctor --fix`, which would repair the wrong file in place — "
+ "then start it again and send your message once more. Advanced recovery steps are "
+ "in the log."
),
"deleted_wal": (
"the session database was changed or replaced while Hermes was running, so this "
"message was not saved (a copy is kept in {home}/sessions/). Stop Hermes "
- "(`hermes {profile_arg}gateway stop`), run `hermes {profile_arg}doctor`, then start it "
- "again and send your "
- "message once more. Advanced recovery steps are in the log."
+ "(`hermes {profile_arg}gateway stop`), run `hermes {profile_arg}doctor`, then start "
+ "it again and send your message once more. Advanced recovery steps are in the log."
),
"corrupt": (
"the turn was stopped because the state database "
@@ -165,9 +164,8 @@ _PERSISTENCE_CAUSE_EXPLANATIONS: Dict[str, str] = {
_PERSISTENCE_DEFAULT_EXPLANATION = (
"Hermes couldn't save this conversation, so it stopped rather than lose your messages. "
"Possible causes: the drive is out of room, or another Hermes process is holding the "
- "database. Close other Hermes windows, run `hermes {profile_arg}doctor` to check storage, "
- "then send "
- "your message again."
+ "database. Close other Hermes windows, run `hermes {profile_arg}doctor` to check "
+ "storage, then send your message again."
)
diff --git a/agent/turn_finalizer.py b/agent/turn_finalizer.py
index bef4a3cd370..a6b06fe60ff 100644
--- a/agent/turn_finalizer.py
+++ b/agent/turn_finalizer.py
@@ -587,10 +587,14 @@ def finalize_turn(
# surfaces status="error" (desktop can toast) instead of a quiet complete frame, plus
# the machine-readable cause 'session_persistence_failed:<locked|compression|...>'.
if failed and str(_turn_exit_reason) == "session_persistence_failed":
- result["error"] = final_response or (
- "session storage could not be written — check the state database "
- "health (`hermes doctor`), then send your message again"
- )
+ if not final_response:
+ from hermes_constants import profile_cli_selector
+
+ final_response = (
+ "session storage could not be written — check the state database "
+ f"health (`hermes {profile_cli_selector()}doctor`), then send your message again"
+ )
+ result["error"] = final_response
_cause = getattr(agent, "_last_persistence_error_cause", None)
result["failure_reason"] = "session_persistence_failed:" + (_cause or "unknown")
elif _exit_failure is not None:
diff --git a/gateway/run_notifications.py b/gateway/run_notifications.py
index a8e13477fdd..3dc5f1a9d5e 100644
--- a/gateway/run_notifications.py
+++ b/gateway/run_notifications.py
@@ -923,7 +923,7 @@ class GatewayNotificationsMixin:
"⚠️ Session database reported a corruption error confined to the search index "
"(FTS5); the message tables are not damaged. Messages may not be persisted until "
f"it is repaired: run `hermes {profile_arg}doctor --fix`, then restart the gateway. Do not run "
- "recovery tools or restore a backup unless `hermes doctor` confirms damage."
+ f"recovery tools or restore a backup unless `hermes {profile_arg}doctor` confirms damage."
)
else:
from hermes_state_user_copy import describe_storage_failure
@@ -931,7 +931,7 @@ class GatewayNotificationsMixin:
message = (
"⚠️ Session database unavailable — messages may not be saved and /resume will be "
f"empty. Cause: {failure.gloss}. Run `hermes {profile_arg}doctor --fix` on the "
- "gateway machine, then `hermes gateway restart`."
+ f"gateway machine, then `hermes {profile_arg}gateway restart`."
)
logger.warning("Broadcasting state.db failure warning to home channels: %s", error)
for platform, _platform_cfg, home, transport in self._home_channel_transports():