Skip to content

feat(gateway): add /workspace command for multi-workspace sessions - #62075

Open
joymadhu49 wants to merge 1 commit into
NousResearch:mainfrom
joymadhu49:feat/workspaces
Open

feat(gateway): add /workspace command for multi-workspace sessions#62075
joymadhu49 wants to merge 1 commit into
NousResearch:mainfrom
joymadhu49:feat/workspaces

Conversation

@joymadhu49

Copy link
Copy Markdown

What

Adds a /workspace slash command to the messaging gateway so a user can register multiple working directories (workspaces) and switch the active one per session — enabling working on two projects concurrently from chat (e.g. two Telegram topics on different workspaces).

Subcommands

  • /workspace / /workspace list — show current + registered workspaces
  • /workspace new <name> [path] — register a workspace (default ~/.hermes/workspaces/<name>, name validated, path created if missing)
  • /workspace <name> / /workspace switch <name> — switch the session's working directory
  • /workspace remove <name> — unregister (never deletes files; falls back cwd if it was active)

Design notes (per AGENTS.md)

  • No new core tool, no new env var — registry persists in config.yaml under gateway.workspaces; the active selection is session routing state on SessionEntry (survives /new resets like other routing state).
  • Prompt-cache safe — switching only updates the terminal/file tool cwd for future turns via the existing register_task_env_overrides mechanism + session DB cwd update; no past-context mutation, no system-prompt rebuild.
  • Profile-aware — config reads/writes run inside _profile_runtime_scope when profile multiplexing is enabled.
  • Follows existing command pattern in GatewaySlashCommandsMixin; registered in the messaging-only command set and documented in website/docs/reference/slash-commands.md.

Testing

  • New tests/gateway/test_workspace_command.py (3 behavior-contract tests): registry CRUD + validation, switch updates session entry + terminal overrides, remove never deletes files. All pass.
  • pytest tests/gateway -k 'session or workspace': 884 passed; the 4-5 failures seen locally also fail on clean upstream/main under the same run order (pre-existing test pollution, unrelated).

🤖 Built with Codex CLI, reviewed and validated before submission.

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery comp/cli CLI entry point, hermes_cli/, setup wizard sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Jul 10, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused gateway feature and the session-routing tests.

Problems

  • gateway/slash_commands.py:200-205 adds env_type to every CWD override. On current main, tools/terminal_tool.py:1142-1155 explicitly reserves env_type as an isolation signal; CWD-only overrides are intended to avoid per-session container creation.
  • gateway/slash_commands.py:201 registers a host path as the tool CWD. tools/terminal_tool.py:2096-2115 discards unusable host CWDs on container backends and falls back to the configured sandbox CWD, so Docker/Modal/Singularity/Daytona do not actually switch workspaces.
  • The branch uses async_session_store (gateway/run.py:10734), but current main uses session_store directly at gateway/run.py:10702; current session concurrency changes include b3f77f5c8270f5a8980daf92c85a57c706f84728.

Suggested changes

  • Keep workspace overrides CWD-only unless a distinct backend environment is intentionally required.
  • Define container mapping/mount behavior and test local plus container mount-on/off paths.
  • Adapt the session-store calls during salvage onto current main.

Automated hermes-sweeper review.

Comment thread gateway/slash_commands.py
if updated is not None:
from tools.terminal_tool import register_task_env_overrides
register_task_env_overrides(updated.session_id, {
"cwd": cwd,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a host path, but container backends reject host-path CWD overrides and fall back to their configured sandbox CWD (tools/terminal_tool.py:2096-2115). Please map only mounted paths to valid in-container paths, or return a clear unsupported/mount-required result.

Comment thread gateway/slash_commands.py
"cwd": cwd,
# Gateway workspaces may run concurrently. Mark this task
# as isolated so two sessions never share a mutable env.cwd.
"env_type": os.environ.get("TERMINAL_ENV", "local"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

env_type is an isolation key in tools/terminal_tool.py:1142-1155; adding it makes this a per-session environment instead of the intended CWD-only override. Remove it unless this command is deliberately provisioning isolated backend environments.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 11, 2026
@teknium1 teknium1 added the area/sessions Session lifecycle, resume, persistence, history label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants