Skip to content

Restore session cwd on resume#21427

Open
gogadoro0524 wants to merge 1 commit into
NousResearch:mainfrom
gogadoro0524:codex/resume-session-cwd
Open

Restore session cwd on resume#21427
gogadoro0524 wants to merge 1 commit into
NousResearch:mainfrom
gogadoro0524:codex/resume-session-cwd

Conversation

@gogadoro0524

Copy link
Copy Markdown

Hi! This is a follow-up to #19154 with the missing consumer added.

In the previous PR, the schema/storage plumbing for session workspace context was clean, but it only wrote workspace_path / last_cwd and nothing read them. This version keeps the same narrow scope, but wires the stored cwd into core resume behavior so the schema bump has an immediate reader.

Summary

  • Adds workspace_path and last_cwd columns to the session store.
  • Stores the current TERMINAL_CWD / process cwd when CLI and agent sessions are created.
  • Updates last_cwd after terminal tool calls by reading the active terminal environment cwd.
  • Restores last_cwd into TERMINAL_CWD during resume flows:
    • early --resume preload
    • _init_agent() fallback resume
    • interactive /resume <session>
  • Keeps local restores conservative: missing/non-absolute local paths are ignored instead of breaking resume.

This means dashboards and remote clients can now rely on persisted workspace context, while the CLI itself also consumes that metadata when resuming a session.

Tests

  • python3 -m py_compile session_workspace.py hermes_state.py cli.py run_agent.py
  • .venv/bin/python -m pytest tests/test_hermes_state.py tests/cli/test_resume_display.py -q
    • 254 passed

I also attempted the broader local suite with the canonical pytest settings. The run reached 20212 passed, but this local environment is missing optional/full extras used by unrelated tests (acp, fastapi, numpy, etc.), so that full run was not green locally.

@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard comp/agent Core agent loop, run_agent.py, prompt builder labels May 7, 2026
@gogadoro0524 gogadoro0524 force-pushed the codex/resume-session-cwd branch from 0438b98 to de07055 Compare May 12, 2026 14:23
@gogadoro0524

Copy link
Copy Markdown
Author

Rebased this on the latest main and resolved the merge conflict with the new handoff session metadata. Since main is already at schema version 12, this now bumps the session schema to 13 while preserving both the handoff fields and the workspace/cwd fields.\n\nRe-ran the focused checks after the rebase:\n\n- python3 -m py_compile session_workspace.py hermes_state.py cli.py run_agent.py\n- .venv/bin/python -m pytest tests/test_hermes_state.py tests/cli/test_resume_display.py -q\n - 256 passed

@gogadoro0524 gogadoro0524 force-pushed the codex/resume-session-cwd branch from de07055 to f475931 Compare May 16, 2026 13:15
@gogadoro0524

Copy link
Copy Markdown
Author

Rebased again on latest main and resolved the new conflict in run_agent.py by preserving both the upstream file-mutation verifier bookkeeping and the session cwd persistence update.\n\nFocused checks after this rebase:\n\n- python3 -m py_compile session_workspace.py hermes_state.py cli.py run_agent.py\n- .venv/bin/python -m pytest tests/test_hermes_state.py tests/cli/test_resume_display.py -q\n - 256 passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants