Skip to content

Persist session workspace context#19154

Closed
gogadoro0524 wants to merge 1 commit into
NousResearch:mainfrom
gogadoro0524:codex/persist-session-workspaces
Closed

Persist session workspace context#19154
gogadoro0524 wants to merge 1 commit into
NousResearch:mainfrom
gogadoro0524:codex/persist-session-workspaces

Conversation

@gogadoro0524

Copy link
Copy Markdown

Hi! Context: I’m a Korean developer and a heavy user of Codex and Claude Code-style agentic coding workflows. In those tools, persisted workspace context is part of what makes session resume feel reliable; I noticed Hermes doesn’t currently persist that context.

Hermes can restore transcript history, but it doesn’t persist which workspace/directories a session was associated with. For local CLI use this is often implicit, but for dashboards, remote clients, resume flows, and multi-repo workflows, it would be useful to persist at least the primary workspace and last cwd.

Summary

This PR adds a small first step toward persisted workspace context for sessions:

  • Adds workspace_path and last_cwd columns to the session store.
  • Allows create_session() and ensure_session() to persist those values.
  • Stores the current TERMINAL_CWD/os.getcwd() context for CLI-created sessions and fallback session creation.
  • Adds update_session_cwd() as a small SessionDB helper for callers that can observe cwd changes.
  • Covers creation, fallback creation, migration, and export behavior in tests/test_hermes_state.py.

I kept this intentionally narrow. A richer follow-up could track multiple referenced workspaces/directories per session, but this gives clients a stable primary workspace and current/last cwd field without changing existing session behavior.

Tests

  • python3 -m py_compile hermes_state.py cli.py run_agent.py
  • uv run --extra dev pytest tests/test_hermes_state.py -q
  • git diff --check

@alt-glitch alt-glitch added type/feature New feature or request comp/agent Core agent loop, run_agent.py, prompt builder comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have labels May 3, 2026
@gogadoro0524 gogadoro0524 force-pushed the codex/persist-session-workspaces branch from 90a93bb to dfc8383 Compare May 4, 2026 09:40
@gogadoro0524

Copy link
Copy Markdown
Author

Rebased on the latest main and resolved the merge conflicts from the recent lazy session creation changes. Re-ran the focused checks:\n\n- python3 -m py_compile hermes_state.py cli.py run_agent.py\n- uv run --extra dev pytest tests/test_hermes_state.py -q (208 passed)\n- git diff --check

@gogadoro0524 gogadoro0524 force-pushed the codex/persist-session-workspaces branch from dfc8383 to 5a0adbf Compare May 5, 2026 03:05
@gogadoro0524

gogadoro0524 commented May 5, 2026

Copy link
Copy Markdown
Author

Rebased again on the latest main after the branch drifted into conflicts. The only manual conflict this time was in tests/test_hermes_state.py; the implementation files rebased cleanly.

Re-ran:

  • python3 -m py_compile hermes_state.py cli.py run_agent.py
  • uv run --extra dev pytest tests/test_hermes_state.py -q (213 passed)
  • git diff --check

GitHub now reports the PR as mergeable again.

@teknium1

teknium1 commented May 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR! The idea — persist session workspace so dashboards/resume flows can restore it — is sound, but right now the change writes two columns to sessions that nothing reads. Per our contribution guidelines, we prefer not to land schema-bumping infrastructure without a concrete consumer in the same PR (speculative fields have a way of diverging from what their eventual consumer actually needs).

If you resubmit alongside a consumer — e.g. /resume restoring last_cwd into TERMINAL_CWD, or a dashboard field showing the workspace path — I'd be glad to take another look. The plumbing itself (schema bump, update_session_cwd, _session_workspace_metadata()) is clean; just needs a reader to justify the DB change.

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 P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants