Skip to content

fix: enforce config.yaml as sole CWD source + deprecate .env CWD vars + add hermes memory reset#11029

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-ed039711
Apr 16, 2026
Merged

fix: enforce config.yaml as sole CWD source + deprecate .env CWD vars + add hermes memory reset#11029
teknium1 merged 1 commit into
mainfrom
hermes/hermes-ed039711

Conversation

@teknium1

@teknium1 teknium1 commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Summary

config.yaml terminal.cwd is the single source of truth for working directory. MESSAGING_CWD and TERMINAL_CWD in .env are deprecated with a migration warning at startup.

Bug report: @sato942_ on Twitter — profile .env not enforcing TERMINAL_CWD/MESSAGING_CWD, causing memory contamination between profiles.

Root cause: The setup wizard was putting MESSAGING_CWD into .env, violating our own rule that .env is for secrets only. Meanwhile, config.yaml terminal.cwd works correctly and always has.

What changed

1. Deprecate MESSAGING_CWD / TERMINAL_CWD in .env

  • Removed MESSAGING_CWD from OPTIONAL_ENV_VARS — setup wizard no longer prompts for it
  • Added warn_deprecated_cwd_env_vars() — prints migration hint at gateway startup when deprecated env vars are detected:
    ⚠ Deprecated .env settings detected:
      ⚠ MESSAGING_CWD=/some/path found in .env — this is deprecated.
      Move to config.yaml instead:  terminal:
        cwd: /your/project/path
      Then remove the old entries from ~/.hermes/.env
    

2. Gateway: TERMINAL_CWD is the canonical env var

  • Replaced all MESSAGING_CWD reads in gateway/run.py with TERMINAL_CWD (bridged from config.yaml)
  • MESSAGING_CWD still works as backward-compat fallback (with the deprecation warning)
  • Config bridge skips writing placeholder values (".", "auto", "cwd") to TERMINAL_CWD

3. Lazy-import guard in cli.py (#10817)

When cli.py is imported lazily during gateway runtime (via delegate_tool → CLI_CONFIG), load_cli_config() used to resolve "." to os.getcwd() — which under systemd/launchd is the repo root. This overwrote the gateway's correctly-resolved TERMINAL_CWD. Now it checks for an already-resolved value first.

4. New: hermes memory reset command

hermes memory reset              # Interactive confirmation
hermes memory reset --yes        # Skip confirmation  
hermes memory reset --target user  # Only wipe USER.md
hermes -p myprofile memory reset --yes  # Profile-scoped

Migration path

# Old way (deprecated, now shows warning):
# .env: MESSAGING_CWD=/my/project

# New way:
hermes config set terminal.cwd /my/project
# Then remove MESSAGING_CWD from .env

Tests

  • 6 lazy-import guard tests
  • 7 gateway placeholder skip tests
  • 5 deprecation warning tests
  • 9 memory reset tests
  • All pass, existing suite unaffected

Issues addressed

Addresses #10225, #4672, #10817, #7663

… + add hermes memory reset

config.yaml terminal.cwd is now the single source of truth for working
directory. MESSAGING_CWD and TERMINAL_CWD in .env are deprecated with a
migration warning.

Changes:

1. config.py: Remove MESSAGING_CWD from OPTIONAL_ENV_VARS (setup wizard
   no longer prompts for it). Add warn_deprecated_cwd_env_vars() that
   prints a migration hint when deprecated env vars are detected.

2. gateway/run.py: Replace all MESSAGING_CWD reads with TERMINAL_CWD
   (which is bridged from config.yaml terminal.cwd). MESSAGING_CWD is
   still accepted as a backward-compat fallback with deprecation warning.
   Config bridge skips cwd placeholder values so they don't clobber
   the resolved TERMINAL_CWD.

3. cli.py: Guard against lazy-import clobbering — when cli.py is
   imported lazily during gateway runtime (via delegate_tool), don't
   let load_cli_config() overwrite an already-resolved TERMINAL_CWD
   with os.getcwd() of the service's working directory. (#10817)

4. hermes_cli/main.py: Add 'hermes memory reset' command with
   --target all/memory/user and --yes flags. Profile-scoped via
   HERMES_HOME.

Migration path for users with .env settings:
  Remove MESSAGING_CWD / TERMINAL_CWD from .env
  Add to config.yaml:
    terminal:
      cwd: /your/project/path

Addresses: #10225, #4672, #10817, #7663
@teknium1 teknium1 force-pushed the hermes/hermes-ed039711 branch from 160e585 to 742e3ce Compare April 16, 2026 13:36
@teknium1 teknium1 changed the title fix: respect profile .env TERMINAL_CWD + add hermes memory reset fix: enforce config.yaml as sole CWD source + deprecate .env CWD vars + add hermes memory reset Apr 16, 2026
@teknium1 teknium1 merged commit 3c42064 into main Apr 16, 2026
6 of 7 checks passed
@teknium1 teknium1 deleted the hermes/hermes-ed039711 branch April 16, 2026 13:48
loongfay pushed a commit to YuanbaoTeam/hermes-agent that referenced this pull request Apr 16, 2026
… + add hermes memory reset (NousResearch#11029)

config.yaml terminal.cwd is now the single source of truth for working
directory. MESSAGING_CWD and TERMINAL_CWD in .env are deprecated with a
migration warning.

Changes:

1. config.py: Remove MESSAGING_CWD from OPTIONAL_ENV_VARS (setup wizard
   no longer prompts for it). Add warn_deprecated_cwd_env_vars() that
   prints a migration hint when deprecated env vars are detected.

2. gateway/run.py: Replace all MESSAGING_CWD reads with TERMINAL_CWD
   (which is bridged from config.yaml terminal.cwd). MESSAGING_CWD is
   still accepted as a backward-compat fallback with deprecation warning.
   Config bridge skips cwd placeholder values so they don't clobber
   the resolved TERMINAL_CWD.

3. cli.py: Guard against lazy-import clobbering — when cli.py is
   imported lazily during gateway runtime (via delegate_tool), don't
   let load_cli_config() overwrite an already-resolved TERMINAL_CWD
   with os.getcwd() of the service's working directory. (NousResearch#10817)

4. hermes_cli/main.py: Add 'hermes memory reset' command with
   --target all/memory/user and --yes flags. Profile-scoped via
   HERMES_HOME.

Migration path for users with .env settings:
  Remove MESSAGING_CWD / TERMINAL_CWD from .env
  Add to config.yaml:
    terminal:
      cwd: /your/project/path

Addresses: NousResearch#10225, NousResearch#4672, NousResearch#10817, NousResearch#7663
vcruzdesigns pushed a commit to vcruzdesigns/Hermes-Atlas that referenced this pull request Apr 16, 2026
… + add hermes memory reset (NousResearch#11029)

config.yaml terminal.cwd is now the single source of truth for working
directory. MESSAGING_CWD and TERMINAL_CWD in .env are deprecated with a
migration warning.

Changes:

1. config.py: Remove MESSAGING_CWD from OPTIONAL_ENV_VARS (setup wizard
   no longer prompts for it). Add warn_deprecated_cwd_env_vars() that
   prints a migration hint when deprecated env vars are detected.

2. gateway/run.py: Replace all MESSAGING_CWD reads with TERMINAL_CWD
   (which is bridged from config.yaml terminal.cwd). MESSAGING_CWD is
   still accepted as a backward-compat fallback with deprecation warning.
   Config bridge skips cwd placeholder values so they don't clobber
   the resolved TERMINAL_CWD.

3. cli.py: Guard against lazy-import clobbering — when cli.py is
   imported lazily during gateway runtime (via delegate_tool), don't
   let load_cli_config() overwrite an already-resolved TERMINAL_CWD
   with os.getcwd() of the service's working directory. (NousResearch#10817)

4. hermes_cli/main.py: Add 'hermes memory reset' command with
   --target all/memory/user and --yes flags. Profile-scoped via
   HERMES_HOME.

Migration path for users with .env settings:
  Remove MESSAGING_CWD / TERMINAL_CWD from .env
  Add to config.yaml:
    terminal:
      cwd: /your/project/path

Addresses: NousResearch#10225, NousResearch#4672, NousResearch#10817, NousResearch#7663
ulasbilgen pushed a commit to ulasbilgen/hermes-adhd-agent that referenced this pull request May 1, 2026
… + add hermes memory reset (NousResearch#11029)

config.yaml terminal.cwd is now the single source of truth for working
directory. MESSAGING_CWD and TERMINAL_CWD in .env are deprecated with a
migration warning.

Changes:

1. config.py: Remove MESSAGING_CWD from OPTIONAL_ENV_VARS (setup wizard
   no longer prompts for it). Add warn_deprecated_cwd_env_vars() that
   prints a migration hint when deprecated env vars are detected.

2. gateway/run.py: Replace all MESSAGING_CWD reads with TERMINAL_CWD
   (which is bridged from config.yaml terminal.cwd). MESSAGING_CWD is
   still accepted as a backward-compat fallback with deprecation warning.
   Config bridge skips cwd placeholder values so they don't clobber
   the resolved TERMINAL_CWD.

3. cli.py: Guard against lazy-import clobbering — when cli.py is
   imported lazily during gateway runtime (via delegate_tool), don't
   let load_cli_config() overwrite an already-resolved TERMINAL_CWD
   with os.getcwd() of the service's working directory. (NousResearch#10817)

4. hermes_cli/main.py: Add 'hermes memory reset' command with
   --target all/memory/user and --yes flags. Profile-scoped via
   HERMES_HOME.

Migration path for users with .env settings:
  Remove MESSAGING_CWD / TERMINAL_CWD from .env
  Add to config.yaml:
    terminal:
      cwd: /your/project/path

Addresses: NousResearch#10225, NousResearch#4672, NousResearch#10817, NousResearch#7663
aj-nt pushed a commit to aj-nt/hermes-agent that referenced this pull request May 1, 2026
… + add hermes memory reset (NousResearch#11029)

config.yaml terminal.cwd is now the single source of truth for working
directory. MESSAGING_CWD and TERMINAL_CWD in .env are deprecated with a
migration warning.

Changes:

1. config.py: Remove MESSAGING_CWD from OPTIONAL_ENV_VARS (setup wizard
   no longer prompts for it). Add warn_deprecated_cwd_env_vars() that
   prints a migration hint when deprecated env vars are detected.

2. gateway/run.py: Replace all MESSAGING_CWD reads with TERMINAL_CWD
   (which is bridged from config.yaml terminal.cwd). MESSAGING_CWD is
   still accepted as a backward-compat fallback with deprecation warning.
   Config bridge skips cwd placeholder values so they don't clobber
   the resolved TERMINAL_CWD.

3. cli.py: Guard against lazy-import clobbering — when cli.py is
   imported lazily during gateway runtime (via delegate_tool), don't
   let load_cli_config() overwrite an already-resolved TERMINAL_CWD
   with os.getcwd() of the service's working directory. (NousResearch#10817)

4. hermes_cli/main.py: Add 'hermes memory reset' command with
   --target all/memory/user and --yes flags. Profile-scoped via
   HERMES_HOME.

Migration path for users with .env settings:
  Remove MESSAGING_CWD / TERMINAL_CWD from .env
  Add to config.yaml:
    terminal:
      cwd: /your/project/path

Addresses: NousResearch#10225, NousResearch#4672, NousResearch#10817, NousResearch#7663
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
… + add hermes memory reset (NousResearch#11029)

config.yaml terminal.cwd is now the single source of truth for working
directory. MESSAGING_CWD and TERMINAL_CWD in .env are deprecated with a
migration warning.

Changes:

1. config.py: Remove MESSAGING_CWD from OPTIONAL_ENV_VARS (setup wizard
   no longer prompts for it). Add warn_deprecated_cwd_env_vars() that
   prints a migration hint when deprecated env vars are detected.

2. gateway/run.py: Replace all MESSAGING_CWD reads with TERMINAL_CWD
   (which is bridged from config.yaml terminal.cwd). MESSAGING_CWD is
   still accepted as a backward-compat fallback with deprecation warning.
   Config bridge skips cwd placeholder values so they don't clobber
   the resolved TERMINAL_CWD.

3. cli.py: Guard against lazy-import clobbering — when cli.py is
   imported lazily during gateway runtime (via delegate_tool), don't
   let load_cli_config() overwrite an already-resolved TERMINAL_CWD
   with os.getcwd() of the service's working directory. (NousResearch#10817)

4. hermes_cli/main.py: Add 'hermes memory reset' command with
   --target all/memory/user and --yes flags. Profile-scoped via
   HERMES_HOME.

Migration path for users with .env settings:
  Remove MESSAGING_CWD / TERMINAL_CWD from .env
  Add to config.yaml:
    terminal:
      cwd: /your/project/path

Addresses: NousResearch#10225, NousResearch#4672, NousResearch#10817, NousResearch#7663
otavio added a commit to otavio/hermes-agent that referenced this pull request May 30, 2026
`hermes_cli/config.py::warn_deprecated_cwd_env_vars` (introduced by NousResearch#11029
to mark `MESSAGING_CWD` as deprecated in favour of `terminal.cwd` in
config.yaml) warns whenever the env var is present in the process env,
regardless of whether `terminal.cwd` is configured. The NixOS module
still emits it on both the native systemd unit (line ~877) and the
container `docker/podman create` invocation (line ~974), so every
`services.hermes-agent.enable = true` host currently sees this warning
on every restart:

  ⚠ Deprecated .env settings detected:
    ⚠ MESSAGING_CWD=/var/lib/hermes/workspace found in .env — this is deprecated.

Surface `workingDirectory` through the canonical
`services.hermes-agent.settings.terminal.cwd` path (with `lib.mkDefault`
so users can override) and drop the deprecated env var from both modes.
In container mode the translation goes through the existing
`containerWorkDir` helper, so the in-container path is correct even
when the host `workingDirectory` lives outside `stateDir`.

Backward compatibility: a user who explicitly sets
`services.hermes-agent.environment.MESSAGING_CWD = "..."` keeps their
override (it still flows into `.env` via the activation script) and
hermes' python loader honours it as the legacy fallback (with the
deprecation warning, which is correct — they've opted in). The
default module-emitted env stops carrying the deprecated path.

Verified against a real deployment:
  nix eval --raw .#nixosConfigurations.<host>.config.systemd.services.hermes-agent.environment \
    --apply 'env: env.MESSAGING_CWD or "ABSENT"'
returns "ABSENT" with the patch, and the rendered config.yaml carries
`terminal.cwd: /var/lib/hermes/workspace` as expected.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
… + add hermes memory reset (NousResearch#11029)

config.yaml terminal.cwd is now the single source of truth for working
directory. MESSAGING_CWD and TERMINAL_CWD in .env are deprecated with a
migration warning.

Changes:

1. config.py: Remove MESSAGING_CWD from OPTIONAL_ENV_VARS (setup wizard
   no longer prompts for it). Add warn_deprecated_cwd_env_vars() that
   prints a migration hint when deprecated env vars are detected.

2. gateway/run.py: Replace all MESSAGING_CWD reads with TERMINAL_CWD
   (which is bridged from config.yaml terminal.cwd). MESSAGING_CWD is
   still accepted as a backward-compat fallback with deprecation warning.
   Config bridge skips cwd placeholder values so they don't clobber
   the resolved TERMINAL_CWD.

3. cli.py: Guard against lazy-import clobbering — when cli.py is
   imported lazily during gateway runtime (via delegate_tool), don't
   let load_cli_config() overwrite an already-resolved TERMINAL_CWD
   with os.getcwd() of the service's working directory. (NousResearch#10817)

4. hermes_cli/main.py: Add 'hermes memory reset' command with
   --target all/memory/user and --yes flags. Profile-scoped via
   HERMES_HOME.

Migration path for users with .env settings:
  Remove MESSAGING_CWD / TERMINAL_CWD from .env
  Add to config.yaml:
    terminal:
      cwd: /your/project/path

Addresses: NousResearch#10225, NousResearch#4672, NousResearch#10817, NousResearch#7663
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
… + add hermes memory reset (NousResearch#11029)

config.yaml terminal.cwd is now the single source of truth for working
directory. MESSAGING_CWD and TERMINAL_CWD in .env are deprecated with a
migration warning.

Changes:

1. config.py: Remove MESSAGING_CWD from OPTIONAL_ENV_VARS (setup wizard
   no longer prompts for it). Add warn_deprecated_cwd_env_vars() that
   prints a migration hint when deprecated env vars are detected.

2. gateway/run.py: Replace all MESSAGING_CWD reads with TERMINAL_CWD
   (which is bridged from config.yaml terminal.cwd). MESSAGING_CWD is
   still accepted as a backward-compat fallback with deprecation warning.
   Config bridge skips cwd placeholder values so they don't clobber
   the resolved TERMINAL_CWD.

3. cli.py: Guard against lazy-import clobbering — when cli.py is
   imported lazily during gateway runtime (via delegate_tool), don't
   let load_cli_config() overwrite an already-resolved TERMINAL_CWD
   with os.getcwd() of the service's working directory. (NousResearch#10817)

4. hermes_cli/main.py: Add 'hermes memory reset' command with
   --target all/memory/user and --yes flags. Profile-scoped via
   HERMES_HOME.

Migration path for users with .env settings:
  Remove MESSAGING_CWD / TERMINAL_CWD from .env
  Add to config.yaml:
    terminal:
      cwd: /your/project/path

Addresses: NousResearch#10225, NousResearch#4672, NousResearch#10817, NousResearch#7663
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant