feat(cli): resume relaunches in the session's original working directory - #38562
Merged
Conversation
… from hermes -c / --resume now reopen a session in its original working directory. The sessions table already had a cwd column; the classic CLI just never wrote or read it. - run_agent._ensure_db_session stamps cwd for local CLI sessions only (new _launch_cwd_for_session gates out gateway/cron and non-local terminal backends, where a host cwd is meaningless to restore). - cli._restore_session_cwd chdir's the process AND retargets TERMINAL_CWD so the terminal tool, code-exec tool, and relative-path resolution all land in the restored dir. Called from both resume paths (interactive run() and the -q single-query path). - Robust degradation: no-op when no cwd recorded, when already there, or when the dir is gone (single dim warning, stays put — no crash).
Contributor
🔎 Lint report:
|
Yuki-14544869
pushed a commit
to Yuki-14544869/hermes-agent
that referenced
this pull request
Jun 4, 2026
… from (NousResearch#38562) hermes -c / --resume now reopen a session in its original working directory. The sessions table already had a cwd column; the classic CLI just never wrote or read it. - run_agent._ensure_db_session stamps cwd for local CLI sessions only (new _launch_cwd_for_session gates out gateway/cron and non-local terminal backends, where a host cwd is meaningless to restore). - cli._restore_session_cwd chdir's the process AND retargets TERMINAL_CWD so the terminal tool, code-exec tool, and relative-path resolution all land in the restored dir. Called from both resume paths (interactive run() and the -q single-query path). - Robust degradation: no-op when no cwd recorded, when already there, or when the dir is gone (single dim warning, stays put — no crash).
davidgut1982
pushed a commit
to davidgut1982/hermes-agent
that referenced
this pull request
Jun 5, 2026
… from (NousResearch#38562) hermes -c / --resume now reopen a session in its original working directory. The sessions table already had a cwd column; the classic CLI just never wrote or read it. - run_agent._ensure_db_session stamps cwd for local CLI sessions only (new _launch_cwd_for_session gates out gateway/cron and non-local terminal backends, where a host cwd is meaningless to restore). - cli._restore_session_cwd chdir's the process AND retargets TERMINAL_CWD so the terminal tool, code-exec tool, and relative-path resolution all land in the restored dir. Called from both resume paths (interactive run() and the -q single-query path). - Robust degradation: no-op when no cwd recorded, when already there, or when the dir is gone (single dim warning, stays put — no crash).
1 task
changman
pushed a commit
to changman/hermes-agent
that referenced
this pull request
Jun 10, 2026
… from (NousResearch#38562) hermes -c / --resume now reopen a session in its original working directory. The sessions table already had a cwd column; the classic CLI just never wrote or read it. - run_agent._ensure_db_session stamps cwd for local CLI sessions only (new _launch_cwd_for_session gates out gateway/cron and non-local terminal backends, where a host cwd is meaningless to restore). - cli._restore_session_cwd chdir's the process AND retargets TERMINAL_CWD so the terminal tool, code-exec tool, and relative-path resolution all land in the restored dir. Called from both resume paths (interactive run() and the -q single-query path). - Robust degradation: no-op when no cwd recorded, when already there, or when the dir is gone (single dim warning, stays put — no crash).
alt-glitch
pushed a commit
that referenced
this pull request
Jun 14, 2026
… from (#38562) hermes -c / --resume now reopen a session in its original working directory. The sessions table already had a cwd column; the classic CLI just never wrote or read it. - run_agent._ensure_db_session stamps cwd for local CLI sessions only (new _launch_cwd_for_session gates out gateway/cron and non-local terminal backends, where a host cwd is meaningless to restore). - cli._restore_session_cwd chdir's the process AND retargets TERMINAL_CWD so the terminal tool, code-exec tool, and relative-path resolution all land in the restored dir. Called from both resume paths (interactive run() and the -q single-query path). - Robust degradation: no-op when no cwd recorded, when already there, or when the dir is gone (single dim warning, stays put — no crash).
kossteg
pushed a commit
to kossteg/hermes-agent
that referenced
this pull request
Jun 16, 2026
… from (NousResearch#38562) hermes -c / --resume now reopen a session in its original working directory. The sessions table already had a cwd column; the classic CLI just never wrote or read it. - run_agent._ensure_db_session stamps cwd for local CLI sessions only (new _launch_cwd_for_session gates out gateway/cron and non-local terminal backends, where a host cwd is meaningless to restore). - cli._restore_session_cwd chdir's the process AND retargets TERMINAL_CWD so the terminal tool, code-exec tool, and relative-path resolution all land in the restored dir. Called from both resume paths (interactive run() and the -q single-query path). - Robust degradation: no-op when no cwd recorded, when already there, or when the dir is gone (single dim warning, stays put — no crash).
T02200059
pushed a commit
to T02200059/hermes-agent
that referenced
this pull request
Jun 18, 2026
… from (NousResearch#38562) hermes -c / --resume now reopen a session in its original working directory. The sessions table already had a cwd column; the classic CLI just never wrote or read it. - run_agent._ensure_db_session stamps cwd for local CLI sessions only (new _launch_cwd_for_session gates out gateway/cron and non-local terminal backends, where a host cwd is meaningless to restore). - cli._restore_session_cwd chdir's the process AND retargets TERMINAL_CWD so the terminal tool, code-exec tool, and relative-path resolution all land in the restored dir. Called from both resume paths (interactive run() and the -q single-query path). - Robust degradation: no-op when no cwd recorded, when already there, or when the dir is gone (single dim warning, stays put — no crash).
xyshanren
pushed a commit
to xyshanren/hermes-agent-cn
that referenced
this pull request
Jun 25, 2026
… from (NousResearch#38562) hermes -c / --resume now reopen a session in its original working directory. The sessions table already had a cwd column; the classic CLI just never wrote or read it. - run_agent._ensure_db_session stamps cwd for local CLI sessions only (new _launch_cwd_for_session gates out gateway/cron and non-local terminal backends, where a host cwd is meaningless to restore). - cli._restore_session_cwd chdir's the process AND retargets TERMINAL_CWD so the terminal tool, code-exec tool, and relative-path resolution all land in the restored dir. Called from both resume paths (interactive run() and the -q single-query path). - Robust degradation: no-op when no cwd recorded, when already there, or when the dir is gone (single dim warning, stays put — no crash).
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
… from (NousResearch#38562) hermes -c / --resume now reopen a session in its original working directory. The sessions table already had a cwd column; the classic CLI just never wrote or read it. - run_agent._ensure_db_session stamps cwd for local CLI sessions only (new _launch_cwd_for_session gates out gateway/cron and non-local terminal backends, where a host cwd is meaningless to restore). - cli._restore_session_cwd chdir's the process AND retargets TERMINAL_CWD so the terminal tool, code-exec tool, and relative-path resolution all land in the restored dir. Called from both resume paths (interactive run() and the -q single-query path). - Robust degradation: no-op when no cwd recorded, when already there, or when the dir is gone (single dim warning, stays put — no crash).
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
… from (NousResearch#38562) hermes -c / --resume now reopen a session in its original working directory. The sessions table already had a cwd column; the classic CLI just never wrote or read it. - run_agent._ensure_db_session stamps cwd for local CLI sessions only (new _launch_cwd_for_session gates out gateway/cron and non-local terminal backends, where a host cwd is meaningless to restore). - cli._restore_session_cwd chdir's the process AND retargets TERMINAL_CWD so the terminal tool, code-exec tool, and relative-path resolution all land in the restored dir. Called from both resume paths (interactive run() and the -q single-query path). - Robust degradation: no-op when no cwd recorded, when already there, or when the dir is gone (single dim warning, stays put — no crash).
donbowman
pushed a commit
to donbowman/hermes-agent
that referenced
this pull request
Jul 13, 2026
… from (NousResearch#38562) hermes -c / --resume now reopen a session in its original working directory. The sessions table already had a cwd column; the classic CLI just never wrote or read it. - run_agent._ensure_db_session stamps cwd for local CLI sessions only (new _launch_cwd_for_session gates out gateway/cron and non-local terminal backends, where a host cwd is meaningless to restore). - cli._restore_session_cwd chdir's the process AND retargets TERMINAL_CWD so the terminal tool, code-exec tool, and relative-path resolution all land in the restored dir. Called from both resume paths (interactive run() and the -q single-query path). - Robust degradation: no-op when no cwd recorded, when already there, or when the dir is gone (single dim warning, stays put — no crash).
1 task
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
… from (NousResearch#38562) hermes -c / --resume now reopen a session in its original working directory. The sessions table already had a cwd column; the classic CLI just never wrote or read it. - run_agent._ensure_db_session stamps cwd for local CLI sessions only (new _launch_cwd_for_session gates out gateway/cron and non-local terminal backends, where a host cwd is meaningless to restore). - cli._restore_session_cwd chdir's the process AND retargets TERMINAL_CWD so the terminal tool, code-exec tool, and relative-path resolution all land in the restored dir. Called from both resume paths (interactive run() and the -q single-query path). - Robust degradation: no-op when no cwd recorded, when already there, or when the dir is gone (single dim warning, stays put — no crash).
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
… from (NousResearch#38562) hermes -c / --resume now reopen a session in its original working directory. The sessions table already had a cwd column; the classic CLI just never wrote or read it. - run_agent._ensure_db_session stamps cwd for local CLI sessions only (new _launch_cwd_for_session gates out gateway/cron and non-local terminal backends, where a host cwd is meaningless to restore). - cli._restore_session_cwd chdir's the process AND retargets TERMINAL_CWD so the terminal tool, code-exec tool, and relative-path resolution all land in the restored dir. Called from both resume paths (interactive run() and the -q single-query path). - Robust degradation: no-op when no cwd recorded, when already there, or when the dir is gone (single dim warning, stays put — no crash).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hermes -c/hermes --resume <id>now reopen a session in the directory it was originally launched from, instead of wherever you happen to be standing.The
sessionstable already had acwdcolumn (and the TUI gateway used it) — the classic CLI just never wrote or read it. This wires up both halves.Changes
run_agent._ensure_db_session: stampscwdon the session row. New_launch_cwd_for_session(source)gates it to local CLI sessions only — gateway/cron sessions and non-local terminal backends (docker/ssh/modal) have no stable host cwd to restore, so they record nothing.cli._restore_session_cwd(session_meta): on resume,os.chdir()s the process and retargetsTERMINAL_CWDso the terminal tool, code-exec tool, and relative-path resolution all land in the restored dir (the local terminal backend snapshots cwd on first use, which happens after this runs). Wired into both resume paths — interactiverun()and the-qsingle-query path.Validation
End-to-end, real CLI, isolated
HERMES_HOME:-qfrom/tmp/dirAcwd=/tmp/dirA--resume <id>from/tmp/dirB, agent runscat marker.txtI-AM-DIR-A+ prints↻ Working directory: /tmp/dirAPlus 15 unit-level E2E assertions covering write-side gating (cli/local records, gateway/docker skip), DB round-trip, chdir +
TERMINAL_CWDretarget, already-there no-op, missing-dir degradation,~expansion, and quiet-mode stderr routing — all pass.Infographic