Problem Description
When the gateway restarts (manually via systemctl restart or crash recovery), sessions that were mid-execution are loaded but the agent doesn't continue. The agent "hangs" waiting for user input.
Scenario:
- User sends message: "check the latest commits"
- Agent starts executing tools (e.g.,
terminal, search_files)
- Gateway restarts mid-execution
- Session history is loaded successfully
- Last message in history is a
tool role response
- Agent waits for new input instead of continuing execution
- User must write "continue" or use
/retry to proceed
Root Cause
When history ends on a tool role message (tool response), the agent doesn't automatically continue the execution loop. The agent expects either:
- User input to start fresh
- An
assistant message to be the last message (completed turn)
But when execution is interrupted by gateway restart, the assistant message was never written — execution stopped after the tool response.
Expected Behavior
After gateway restart, if the loaded session history ends on a tool role message, the agent should automatically continue execution as if it never stopped. This is similar to how /retry works, but should happen automatically.
Workaround
Currently users must either:
- Write "continue" or any message to trigger continuation
- Use
/retry command to re-send the last user message
Proposed Solution
In gateway/run.py, after loading session history, check if the last message is a tool role. If so, automatically trigger a continuation:
# After loading history in _handle_message or similar
history = self.session_store.load_transcript(session_entry.session_id)
if history and len(history) > 0:
last_msg = history[-1]
if last_msg.get("role") == "tool":
# History ends on tool response - execution was interrupted
# Auto-continue by triggering agent with empty continuation prompt
logger.info("Session history ends on tool response, auto-continuing execution")
# ... trigger agent loop continuation
Alternative Solutions
- Add
/continue command — explicit command to resume interrupted execution without re-sending the user message
- Persist execution state — save that agent was mid-execution, restore on startup
- Send system message on restart — gateway sends a "Gateway restarted, continue" system message to agent
Environment
- Hermes Agent v0.6.0 (2026.3.30)
- Gateway running via systemd
- Platform: Telegram
- Session persistence: enabled (default)
Related Code
gateway/run.py — session loading logic around line ~1700
SessionStore.load_transcript() — history loading
_handle_message() — where history is loaded and agent is invoked
Impact
This affects all gateway users who restart their gateway (manually or due to updates/crashes). The interruption of mid-execution tasks is a common pain point for long-running operations.
Problem Description
When the gateway restarts (manually via
systemctl restartor crash recovery), sessions that were mid-execution are loaded but the agent doesn't continue. The agent "hangs" waiting for user input.Scenario:
terminal,search_files)toolrole response/retryto proceedRoot Cause
When history ends on a
toolrole message (tool response), the agent doesn't automatically continue the execution loop. The agent expects either:assistantmessage to be the last message (completed turn)But when execution is interrupted by gateway restart, the
assistantmessage was never written — execution stopped after the tool response.Expected Behavior
After gateway restart, if the loaded session history ends on a
toolrole message, the agent should automatically continue execution as if it never stopped. This is similar to how/retryworks, but should happen automatically.Workaround
Currently users must either:
/retrycommand to re-send the last user messageProposed Solution
In
gateway/run.py, after loading session history, check if the last message is atoolrole. If so, automatically trigger a continuation:Alternative Solutions
/continuecommand — explicit command to resume interrupted execution without re-sending the user messageEnvironment
Related Code
gateway/run.py— session loading logic around line ~1700SessionStore.load_transcript()— history loading_handle_message()— where history is loaded and agent is invokedImpact
This affects all gateway users who restart their gateway (manually or due to updates/crashes). The interruption of mid-execution tasks is a common pain point for long-running operations.