Skip to content

[Feature]: add --profile flag to hermes gateway start/restart for profile-specific gateway instances #44421

Description

@tanghzuk188

Problem or Use Case

The global -p / --profile flag works for some gateway commands (hermes -p stock gateway status) but hermes -p stock gateway start fails with "service not installed" unless the profile has been separately registered as a systemd service.

The only way to run the gateway under a non-default profile today is:

  1. Change the active default profile: hermes profile use stock
  2. Restart the gateway: hermes gateway restart

This is inconvenient when a user wants different profiles for different use cases (e.g., stock research on WeChat vs coding via CLI), because changing the default profile affects all future CLI sessions too.

Also, restarting the gateway while keeping a running profile (e.g., the WeChat gateway on stock) should be possible without switching the user's default profile for CLI sessions.

Proposed Solution

Add a --profile <name> argument to the hermes gateway subcommand group:

hermes gateway start --profile stock
hermes gateway restart --profile dev
hermes gateway status --profile stock

When --profile is supplied, the gateway process should:

  1. Set HERMES_HOME to ~/.hermes/profiles/<name>/ at startup
  2. Load config, .env, skills, and memory from that profile
  3. Register as a separate service instance (if using systemd) so multiple gateway instances can coexist

The implementation can reuse the existing _apply_profile_override() mechanism in hermes_cli/main.py which already resolves --profile and sets HERMES_HOME before module imports — the main work would be threading it through to the gateway subcommand parser.

For systemd users, each profile's gateway should get a distinct service name (e.g., hermes-gateway@stock, hermes-gateway@dev) to allow independent lifecycle management.

Alternatives Considered

  1. Use the global -p flag: Already exists but incomplete — hermes -p stock gateway start fails with "service not installed" and there's no clean way to manage per-profile gateway lifecycle.

  2. Manually switch default profile: hermes profile use stock && hermes gateway restart works but is disruptive — it changes the default for ALL future CLI sessions, not just the gateway.

  3. Run separate Hermes installations: Install Hermes in different locations for each profile. Works but is heavy, duplicates the entire codebase, and loses the unified state management that profiles provide.

  4. Use wrapper scripts: Create shell aliases that set HERMES_HOME before calling gateway commands. Fragile and doesn't integrate with the service management system.

The proposed --profile flag is the most native, discoverable, and maintainable solution that builds on Hermes' existing profile infrastructure.

Feature Type

Gateway / messaging improvement

Scope

None

Contribution

  • I'd like to implement this myself and submit a PR

Debug Report (optional)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/cliCLI entry point, hermes_cli/, setup wizardsweeper:implemented-on-mainSweeper: behavior already present on current maintype/featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions