Your terminal can now relaunch Hermes exactly where you left it


It is the end of the day and your agent is three quarters through a refactor: it knows which test is failing, which file it already touched, and why it stopped. You close the laptop. The next morning the terminal has restarted, the pane is empty, and your only option is to remember a session id.

Terminals have had a partial answer to this for a while. There is a convention — OSC 7577 — that lets a program tell the terminal, “if you ever have to restart me, this is the command that brings me back.” Hermes already used the neighbouring OSC 7501 to report whether a tab is idle, working or blocked. v0.23.5 adds the resume half, so a supporting terminal can put the same session back into the same pane.

What gets reported, in plain words

When Hermes starts in an interactive session, it sends the terminal a resume command shaped like this:

hermes -p PROFILE --cli --resume SESSION_ID
hermes -p PROFILE --tui --resume SESSION_ID

The classic CLI, gateway chat and the Ink TUI all report. When you quit on purpose, they clear it. The terminal decides what to do with the record — restart it in a new pane, offer it in a menu, or ignore it entirely. Hermes does not.

Two conditions keep this from being a surprise: the terminal has to understand the sequence, and the pane has to carry an OSC7577_TOKEN in its environment. Without a token, nothing is reported and nothing changes. If you want to switch it off anyway, display.program_resume: false does it — the same block where program_status lives.

Why a token, and why it leaves the environment

An escape sequence that tells a terminal to run a command is, structurally, remote code execution with extra steps. The token is what makes it safe: the terminal generates it, hands it to the pane, and only accepts a resume record that presents it back. Hermes never invents the value, and the terminal never accepts a record from a process that could not read it.

The subtle part is the children. Once a token is in os.environ, every subprocess Hermes spawns — MCP servers, terminal backends, a plugin host — would inherit it, and any of them could rewrite the pane’s resume record. So load_hermes_dotenv, every entry point’s first environment step, removes it from the environment. Only two consumers get it afterwards: the Node TUI and the /update relaunch. Everything else runs without it.

Cleared on quit, kept on a crash

The interesting design decision is what counts as “done”. Hermes clears the record only on a user quit: /quit, or Ctrl+D — and in gateway chat, Ctrl+D on an empty line is now bound to /quit for exactly this reason. Everything else keeps the record on purpose:

What happened Resume record
/quit or Ctrl+D cleared
Crash, exception, terminal loss kept
Terminal closed by the OS, bare EOF kept
hermes update relaunch kept
Process resumed after SIGCONT re-reported

The logic is that a crash is precisely the case where you want to be offered the session back. A quit is a statement that you are finished. Sending SIGCONT after a stop re-reports the record because the terminal may have dropped it while the process was suspended.

The edge cases that took the follow-up commits

The feature came in as a community pull request (#160297, by @freqyfreqy) and was salvaged and hardened in #160797. Most of the hardening is about not writing a resume command that would open a different store:

  • -p NAME is included only when the profile actually resolves to this Hermes home. A HERMES_HOME outside the profiles root, a custom data root (Docker’s /opt/data, or HERMES_DATA_DIR_SUFFIX) or a named gateway (HERMES_TUI_GATEWAY_URL) gets no profile flag, because relaunching there would start a fresh launch, not this conversation.
  • --resume ID appears only once the session row exists in the store. Reporting it earlier would produce a command that fails on restore.
  • --safe-mode and --ignore-user-config are repeated in the record, and a resume is reported for those launches only when there is a saved session — a bare restart would need the model passed again explicitly.
  • The bookkeeping lives in one ProgramResumeReporter, with writes ordered under a lock, because the SIGCONT re-report runs on a thread.

None of that is visible when it works. All of it is visible when it fails: a resume command that opens an empty session is worse than no resume command at all.

Should you care yet?

If your terminal does not speak OSC 7577, this release costs you nothing — no config, no new output, no behaviour change. If it does, the practical gain is that a pane restart becomes a restore instead of a archaeology exercise. It pairs naturally with the status protocol: OSC 7501 tells the terminal what the tab is doing, OSC 7577 tells it how to get the tab back.

The honest caveat is ecosystem maturity. The protocol only helps when the terminal on the other end implements it, and that support is still thin. Hermes does the correct thing in both directions: it reports when invited, stays silent when not, and never leaves a token lying around for a child process to pick up.

Trying it

There is nothing to install. If your terminal sets OSC7577_TOKEN in the pane, run Hermes as usual:

hermes chat --tui          # or: hermes chat
hermes -p ops chat         # profile included when it resolves to this home

Quit with /quit, and the record disappears. Kill the process instead, restart the terminal, and see what your emulator offers. To opt out entirely:

display:
  program_resume: false

For the sibling half of this story — how Hermes reports idle, working and blocked states to the same terminal — see our OSC 7501 program status guide. For the rest of the window this shipped in, the v0.23.5 rollup is the summary.