Skip to content

fix: bridge HOME_CHANNEL keys from config.yaml to env on Gateway restart#17227

Closed
cooker-code wants to merge 1 commit into
NousResearch:mainfrom
cooker-code:fix/home-channel-persist
Closed

fix: bridge HOME_CHANNEL keys from config.yaml to env on Gateway restart#17227
cooker-code wants to merge 1 commit into
NousResearch:mainfrom
cooker-code:fix/home-channel-persist

Conversation

@cooker-code

Copy link
Copy Markdown

Problem

When a user runs /sethome in a platform (e.g. WeCom), the command writes the home channel info as top-level keys like WECOM_HOME_CHANNEL and WECOM_HOME_CHANNEL_NAME into config.yaml.

However, when the Gateway restarts, load_gateway_config() does not bridge these top-level *_HOME_CHANNEL / *_HOME_CHANNEL_NAME keys back into os.environ. As a result, _apply_env_overrides() cannot pick them up, and the home channel setting is effectively lost after restart — the user has to run /sethome again every time.

Fix

In load_gateway_config(), after loading config.yaml, iterate all top-level keys and bridge any ending with _HOME_CHANNEL or _HOME_CHANNEL_NAME into os.environ (only if the env var is not already set). This ensures _apply_env_overrides() can pick them up.

Changes

  • gateway/config.py: Added 6-line loop to bridge *_HOME_CHANNEL / *_HOME_CHANNEL_NAME keys from YAML config to environment variables

Testing

  1. Configured WeCom with /sethomeconfig.yaml gets WECOM_HOME_CHANNEL and WECOM_HOME_CHANNEL_NAME
  2. Restarted Gateway — verified home channel is now correctly loaded from config
  3. Confirmed _apply_env_overrides() picks up the values as expected

When /sethome writes *_HOME_CHANNEL and *_HOME_CHANNEL_NAME keys
to config.yaml, they were not loaded back into os.environ on
Gateway restart. This caused _apply_env_overrides() to miss them,
effectively losing the home channel setting.

Now load_gateway_config() iterates top-level config keys and bridges
any *_HOME_CHANNEL / *_HOME_CHANNEL_NAME entries into os.environ
(if not already set), ensuring persistence across restarts.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery area/config Config system, migrations, profiles labels Apr 29, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely superseded by #16900 (merged) which persists /sethome via save_env_value() to .env across all platforms. Please verify this PR is still needed after #16900.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the contribution! This fix is superseded by #16900 (merged 2026-04-28, shipped in v2026.4.30), which addresses the same root cause more comprehensively.

This is an automated hermes-sweeper review. @alt-glitch also flagged this in the comments.

Evidence:

  • gateway/run.py line 7972: _handle_set_home_command now calls save_env_value(env_key, str(chat_id)), writing the home channel directly to ~/.hermes/.env and updating os.environ atomically — no config.yaml → env bridging needed
  • Commit 1d5e25f35 (PR fix(gateway): persist /sethome home channel to .env across all platforms #16900) landed 2026-04-28T08:17:18Z, ~18 hours before this PR was opened
  • The fix also widened _EXTRA_ENV_KEYS in hermes_cli/config.py to cover HOME_CHANNEL and HOME_CHANNEL_NAME for all platforms

The .env-based approach is cleaner than YAML bridging because save_env_value() is the canonical persistence path for runtime-configured env vars in Hermes.

@teknium1 teknium1 closed this Jun 10, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants