feat(cli,tui): OSC 7577 program resume (salvage of #160297) #160797
<!-- hermes-ci-review-bot -->
૮ >ﻌ< ა ci review
<sub>ran on fab095c — fix(cli): resume a source launch through this install's own </sub>
ℹ️ Info
CI caches · View report · View job
35 / 35 cache hits (0 misses)
5278.56 MiB restored
0 B not restored.
<details>
<summary>per-job cache results</summary>
<h3>hits</h3>
<table><thead><tr><th>Job</th><th>Step</th><th>Logs</th><th>Restored</th><th>Δ vs main</th></tr></thead><tbody>
<tr><td>OS-specific tests / Windows-only tests (arm64, 1/2)</td><td>Set up native ARM64 build dependencies / Cache ARM64 OpenSSL development files</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584973#step:3:1">view step</a></td><td>26.23 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / Windows-only tests (arm64, 1/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584973#step:4:1">view step</a></td><td>222.58 MiB</td><td>unknown</td></tr>
<tr><td>OS-specific tests / Windows-only tests (arm64, 1/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584973#step:4:1">view step</a></td><td>856.03 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / Windows-only tests (arm64, 2/2)</td><td>Set up native ARM64 build dependencies / Cache ARM64 OpenSSL development files</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584852#step:3:1">view step</a></td><td>26.23 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / Windows-only tests (arm64, 2/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584852#step:4:1">view step</a></td><td>222.58 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / Windows-only tests (arm64, 2/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584852#step:4:1">view step</a></td><td>856.03 MiB</td><td>+0 B</td></tr>
<tr><td>JS & TS checks / JS & TS checks</td><td>Set up the locked JS build toolchain / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608582935#step:4:1">view step</a></td><td>155.42 MiB</td><td>unknown</td></tr>
<tr><td>JS & TS checks / JS & TS checks</td><td>Set up the locked JS build toolchain / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608582935#step:4:1">view step</a></td><td>43.14 MiB</td><td>+0 B</td></tr>
<tr><td>JS & TS checks / JS & TS checks</td><td>Set up the locked JS build toolchain / Restore node dependency downloads</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608582935#step:4:1">view step</a></td><td>180.90 MiB</td><td>+0 B</td></tr>
<tr><td>JS & TS checks / JS & TS checks</td><td>Restore node_modules</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608582935#step:6:1">view step</a></td><td>262.53 MiB</td><td>+0 B</td></tr>
<tr><td>Docs Site / docs-site-checks</td><td>Set up the locked site toolchain / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608583001#step:4:1">view step</a></td><td>155.42 MiB</td><td>unknown</td></tr>
<tr><td>Docs Site / docs-site-checks</td><td>Install website dependencies / Restore node dependency downloads</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608583001#step:5:1">view step</a></td><td>71.71 MiB</td><td>unknown</td></tr>
<tr><td>Repository guards / Repository guards</td><td>Run ./.github/actions/setup-pm / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608583256#step:36:1">view step</a></td><td>155.42 MiB</td><td>+0 B</td></tr>
<tr><td>Repository guards / Repository guards</td><td>Run ./.github/actions/setup-pm / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608583256#step:36:1">view step</a></td><td>43.14 MiB</td><td>+0 B</td></tr>
<tr><td>Repository guards / Repository guards</td><td>Run ./.github/actions/setup-pm / Restore node dependency downloads</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608583256#step:36:1">view step</a></td><td>180.90 MiB</td><td>+0 B</td></tr>
<tr><td>Python tests / Run tests (2/3)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584347#step:5:1">view step</a></td><td>154.96 MiB</td><td>+0 B</td></tr>
<tr><td>Python tests / Run tests (2/3)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584347#step:5:1">view step</a></td><td>43.14 MiB</td><td>+0 B</td></tr>
<tr><td>Python tests / Run tests (2/3)</td><td>Run tests</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584347#step:8:1">view step</a></td><td>0.10 MiB</td><td>-35 B</td></tr>
<tr><td>Remote terminal backends / SSH + Docker backends (real sshd, real daemon)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584349#step:6:1">view step</a></td><td>83.14 MiB</td><td>unknown</td></tr>
<tr><td>Remote terminal backends / SSH + Docker backends (real sshd, real daemon)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584349#step:6:1">view step</a></td><td>43.14 MiB</td><td>+0 B</td></tr>
<tr><td>Python tests / Run tests (1/3)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584448#step:5:1">view step</a></td><td>154.96 MiB</td><td>unknown</td></tr>
<tr><td>Python tests / Run tests (1/3)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584448#step:5:1">view step</a></td><td>43.14 MiB</td><td>+0 B</td></tr>
<tr><td>Python tests / Run tests (1/3)</td><td>Run tests</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584448#step:8:1">view step</a></td><td>0.10 MiB</td><td>+73 B</td></tr>
<tr><td>Python tests / Run tests (3/3)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584480#step:5:1">view step</a></td><td>154.96 MiB</td><td>unknown</td></tr>
<tr><td>Python tests / Run tests (3/3)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584480#step:5:1">view step</a></td><td>43.14 MiB</td><td>+0 B</td></tr>
<tr><td>Python tests / Run tests (3/3)</td><td>Run tests</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584480#step:8:1">view step</a></td><td>0.10 MiB</td><td>+0 B</td></tr>
<tr><td>Catalog tests / Catalog tests</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584487#step:4:1">view step</a></td><td>83.14 MiB</td><td>unknown</td></tr>
<tr><td>Catalog tests / Catalog tests</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584487#step:4:1">view step</a></td><td>43.14 MiB</td><td>+0 B</td></tr>
<tr><td>Python lints / Python lints</td><td>Run ./.github/actions/setup-pm / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608585452#step:4:1">view step</a></td><td>83.14 MiB</td><td>unknown</td></tr>
<tr><td>OS-specific tests / macOS-only tests (1/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584838#step:5:1">view step</a></td><td>107.86 MiB</td><td>unknown</td></tr>
<tr><td>OS-specific tests / macOS-only tests (1/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584838#step:5:1">view step</a></td><td>167.62 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / macOS-only tests (2/2)</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584889#step:5:1">view step</a></td><td>107.86 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / macOS-only tests (2/2)</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584889#step:5:1">view step</a></td><td>167.62 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / Windows-only tests</td><td>Set up locked Python and test dependencies / Restore verified PM tools without saving</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584919#step:5:1">view step</a></td><td>236.13 MiB</td><td>+0 B</td></tr>
<tr><td>OS-specific tests / Windows-only tests</td><td>Set up locked Python and test dependencies / Restore uv dependency downloads and builds</td><td><a href="https://github.com/NousResearch/hermes-agent/actions/runs/46029206395/job/140608584919#step:5:1">view step</a></td><td>102.91 MiB</td><td>+0 B</td></tr>
</tbody></table>
<h3>misses</h3>
none
<p>Compressed archive bytes. Not-restored bytes use the main-size reference; missing sizes remain unknown.</p>
</details>
---
debug info
<details>
<summary>CI timings</summary>
CI timings · View report · View job
Wall time 6m43s vs 6m22s (+5.5%). 8 job(s) slower, 7 faster, 1 unchanged.
</details>
<!-- greptile_summary -->
<h2><ruby><rp>Confidence Score: 5/5 · The PR appears safe to merge; all previous findings are addressed, with no new actionable issues found.</rp></ruby><a href="https://app.greptile.com/api/retrigger?id=121868037&sig=1c437e45ff179afa82d48d29eda84cdf786774cd03b9f3f8b68910a316b33965"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/-/switch-tenant?tenant=nous-research&next=%2FNousResearch%2Fhermes-agent%2Fpull%2F160797&utm_source=greptile_review&utm_medium=github&utm_campaign=view_in_greptile"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 5/5</h2>
[Medium impact] The PR appears safe to merge; all previous findings are addressed, with no new actionable issues found.
<details><summary><h3>Summary</h3></summary>
Adds authenticated OSC 7577 resume reports across the classic CLI, gateway chat, and Ink TUI.
</details>
<details open><summary><h3>Diagram</h3></summary>
%%{init: {'theme': 'neutral'}}%%
flowchart TD
Launch[Start Hermes with pane token] --> Command[Build install-bound resume command]
Command --> Report[Report command to terminal]
Saved[Session is saved] --> Resume[Add --resume and session ID]
Resume --> Report
Report --> Quit{Why did Hermes exit?}
Quit -->|User quit| Clear[Clear terminal record]
Quit -->|Signal, crash, or relaunch| Keep[Keep terminal record]
</details>
<!-- greptile_confidence_score:5 -->
<sub>Reviews (3) · Last reviewed commit: "fix(cli): resume a source launch through..." · Reviewed by Greptile</sub>
<a href=""><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> Source launches cannot restart
If Hermes was started from a source checkout that relies on PYTHONPATH, this fallback saves a command that loses the checkout path in a fresh terminal. Replaying sys.executable -m hermes_cli.main outside the checkout then fails with ModuleNotFoundError instead of reopening the chat. PM's development environment supports this launch setup.
Use an install-bound command, such as installation_command(), rather than relying on the old shell's environment.
<details><summary>Prompt To Fix With AI</summary>
``This is a comment left during a code review.
Path: hermes_cli/program_resume.py
Line: 38
Comment:
**Source launches cannot restart**
If Hermes was started from a source checkout that relies on `PYTHONPATH`, this fallback saves a command that loses the checkout path in a fresh terminal. Replaying `sys.executable -m hermes_cli.main` outside the checkout then fails with `ModuleNotFoundError` instead of reopening the chat. PM's development environment supports this launch setup.
Use an install-bound command, such as `installation_command()`, rather than relying on the old shell's environment.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
</details>
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
<a href=""><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> The opt-out lacks coverage
The CLI guide requires each new config key to have a test that writes a temporary config.yaml and checks behavior through the real loader. The new program_resume test replaces load_user_config_effective with a lambda, so it does not meet that requirement.
Before merging, add a file-backed opt-out test that loads display.program_resume: false and checks that no report is written.
Context Used: hermes_cli/AGENTS.md (source)
<details><summary>Prompt To Fix With AI</summary>
``This is a comment left during a code review.
Path: hermes_cli/config_defaults.py
Line: 838
Comment:
**The opt-out lacks coverage**
The CLI guide requires each new config key to have a test that writes a temporary `config.yaml` and checks behavior through the real loader. The new `program_resume` test replaces `load_user_config_effective` with a lambda, so it does not meet that requirement.
Before merging, add a file-backed opt-out test that loads `display.program_resume: false` and checks that no report is written.
**Context Used:** hermes_cli/AGENTS.md ([source](https://github.com/nousresearch/hermes-agent/blob/main/hermes_cli/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
</details>
<a href=""><img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"></a> macOS misses signal coverage
This test gates SIGCONT with pytest.skip() instead of the required @pytest.mark.platforms("posix"). macOS CI selects files by that marker and runs marked tests only, so it never checks this new signal behavior.
Before merging, add the platform marker and remove the manual host skip, as the test guide requires.
Context Used: tests/AGENTS.md (source)
<details><summary>Prompt To Fix With AI</summary>
``This is a comment left during a code review.
Path: tests/hermes_cli/test_program_resume.py
Line: 351-352
Comment:
**macOS misses signal coverage**
This test gates `SIGCONT` with `pytest.skip()` instead of the required `@pytest.mark.platforms("posix")`. macOS CI selects files by that marker and runs marked tests only, so it never checks this new signal behavior.
Before merging, add the platform marker and remove the manual host skip, as the test guide requires.
**Context Used:** tests/AGENTS.md ([source](https://github.com/nousresearch/hermes-agent/blob/main/tests/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
</details>
Fixed in fab095cde0: a source / python -m launch now reports chat_launch.hermes_command() (the install's launcher, or this interpreter with the inline bootstrap that drops PYTHONPATH). Replayed the reported argv under env -i from outside the checkout: it starts this install. The test now expects the install command and fails against the old -m form.
Added in fab095cde0: test_a_config_file_opt_out_writes_no_report writes display.program_resume: false to a temp HERMES_HOME's config.yaml, goes through the real load_user_config_effective, and checks that no OSC 7577 report is written. It fails when the setting is ignored.
Fixed in fab095cde0: marked @pytest.mark.platforms("posix") and removed the manual skip.
Bonjour, revue du code : bonne qualité, tests mentionnés, pas de problèmes de sécurité.
Bonjour, revue du code : bonne qualité, tests mentionnés, pas de problèmes de sécurité.
Bonjour, revue rapide de la PR #160797 (feat(cli,tui): OSC 7577 program resume (salvage of #160297)) dans NousResearch/hermes-agent.
Vérification rapide : code pertinent, tests mentionnés, pas de secrets exposés. Prêt pour merge après approbation.
✅ Code review validé. CI : succès. Attend une approbation manuelle pour merge.
kshitijk4poor
Salvage of #160297 by @freqyfreqy (opened 2026-11-26): OSC 7577 Program Resume, so a terminal that supports it can restart Hermes in a pane with the session it was showing. Their commit is kept as-is with authorship (contributor email mapped in the first commit); two follow-up commits fix what review found.
What it does
Hermes reports the pane's resume command (
hermes -p PROFILE --cli|--tui [--resume ID]) to the terminal, authenticated with the terminal'sOSC7577_TOKEN, and clears it when the user ends Hermes. Classic CLI, gateway chat and the Ink TUI all report.display.program_resume: falseturns it off. Nothing changes without a token.Fixes on top of the contributor commit
Python (classic CLI, gateway chat, launcher):
ProgramResumeReporterinstead of two copies of the bookkeeping; writes ordered under a lock (the SIGCONT re-report runs on a thread).-p NAMEonly when the profile resolves to this home; nothing for a HERMES_HOME outside the profiles root, a custom root (Docker/opt/data,HERMES_DATA_DIR_SUFFIX) or a named gateway (HERMES_TUI_GATEWAY_URL), where a fresh launch would open another store.--safe-mode/--ignore-user-configlaunches repeat the flag and report only with a saved session (a bare restart would need the explicit model again). Gateway chat takes the flag from its args.--resume IDonly once the session store holds the row./quit, Ctrl+D; in gateway chat Ctrl+D on an empty line is now a/quitbinding). Signals, terminal loss, an exception, a bare EOF and the/updaterelaunch keep the record. Both clients report again after SIGCONT.os.environinload_hermes_dotenv(every entry point's first env step, before secret-source commands run), so no child inherits it; it is handed only to the Node TUI and the/updaterelaunch. This replaces per-call-site stripping.TUI:
--resume IDonly for a session the gateway confirmed saved: an inline turn'sprompt.submitstreaminganswer, or a resume with stored history. Token usage, a built agent or a pending submit no longer count./update, a crash, a signal and a dead output stream keep it.Validation
tests/hermes_cli/test_program_resume.py(44),test_terminal_notify.py(13),test_agent_env_advertisement.py(3); TUIprogramResume.test.ts+submissionCore.test.ts(34); tsc, eslint, ruff, scripts/check. Every new guard was mutation-checked (test fails with the guard removed).--cli): start, first turn, Ctrl+D clear, terminal loss / SIGTERM / SIGHUP keep, SIGSTOP+SIGCONT re-report,--safe-modereports--safe-mode --resume ID, setting off / no token / custom root report nothing,!envshows noOSC7577_TOKEN. The Ink TUI was checked at the launcher hand-off (token + prefix to node), not interactively./newthen/quithangs in this harness on this branch and on main alike (pre-existing, not touched here).Known limitations
--resumefor a session the restart cannot find. A proper fix needs the gateway to attest the row in its response (a contract change), left out of this PR.Closes #160297 once merged.