Skip to content

Profile switching fully broken in Gateway/WebUI/Telegram - HERMES_HOME guard blocks active_profile #22502

@zunami

Description

@zunami

Bug Report: Profile switching is completely non-functional in the Hermes Gateway (Workspace WebUI, Telegram, and all non-CLI platforms).

Summary

hermes profile use NAME works perfectly in the CLI. New shell, new profile. But the Gateway, Workspace WebUI, and Telegram all ignore the active profile and always run as the Default profile.

Test Protocol (Hermes v2.3.0)

Test 1 - CLI profile switching ✅ PASS

Steps:

  1. hermes profile create USER --clone
  2. hermes profile use USER
  3. hermes config get agent.name

Result: Correctly returns USER profile config. Profile switching works in CLI.


Test 2 - Gateway WebUI ❌ FAIL

Steps:

  1. After hermes profile use USER
  2. hermes gateway start
  3. Open Workspace WebUI
  4. Check system status or model

Result: WebUI shows Default profile config, not USER. Active profile is ignored.


Test 3 - Telegram ❌ FAIL

Steps:

  1. After hermes profile use USER
  2. Send message to Telegram bot

Result: Bot responds with Default profile personality/config. USER profile not loaded.


Test 4 - systemd service overrides profile ⚠️ CONFIRMED

Result: /etc/systemd/system/hermes-gateway.service contains:

Environment=HERMES_HOME=/root/.hermes

This is hardcoded and blocks profile switching.


Test 5 - Code inspection (Root Cause)

Two blocking code locations:

(a) hermes/core/prefixed_env.py -> get_env_path()python if env_home := os.environ.get("HERMES_HOME"): return Path(env_home) If HERMES_HOME is set (which systemd does), the function returns early at line ~70. It never checks active_profile.

(b) hermes/gateway/main.py -> _apply_profile_override()python if os.environ.get("HERMES_HOME"): return # already overridden, skip profile This means any process started by systemd (gateway, webui, telegram) never reads ~/.hermes/active_profile.


Test 6 - .env and profile separation ❌ BROKEN

The .env file lives at /root/.hermes/.env, shared across all profiles. A profile cannot have its own API keys or environment variables.

Related Issues (all open)

Issue Title
#16582 (P2) WebUI sessions stored in wrong profile directory
#19299 (P2) hermes profile use broken after update
#19113 (P2) Gateway stores data in wrong home
#16264 Gateway runs in wrong context
#12099 build_session_key() hardcodes agent:main
#7663 SystemD profile support request

Expected Behavior

Switching profiles in the CLI should also switch the profile used by the Gateway, WebUI, Telegram, and all other Hermes services. OR the profile system should be transparent to the Gateway (the Gateway should read active_profile and adjust HERMES_HOME accordingly).

Workaround (hack - not recommended)

Modify get_env_path() to read ~/.hermes/active_profile and re-derive HERMES_HOME from it, plus remove HERMES_HOME from systemd. But this requires patching source code and re-deploying.

Suggested Fix Architecture

  1. Remove HERMES_HOME from systemd/gateway startup
  2. Make get_env_path() the single source of truth: read active_profile, resolve to profiles/NAME/, fall back to default
  3. Ensure Gateway calls get_env_path() on every request (not cached at startup)
  4. Optionally: hermes profile use could restart the gateway service via systemctl --user

Labels: type/bug area/gateway area/config


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions