hermes - ✅(Solved) Fix Feishu `/sethome` silently fails: home channel not persisted, prompts every startup [2 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#16806Fetched 2026-04-29 06:38:59
View on GitHub
Comments
1
Participants
2
Timeline
11
Reactions
0
Timeline (top)
labeled ×5cross-referenced ×2referenced ×2closed ×1

Running /sethome in a Feishu DM appears to succeed (the command returns the confirmation message), but the home channel is not actually persisted. After every gateway restart, Hermes prompts 📬 No home channel is set for Feishu. Type /sethome to make this chat your home channel... again.

I've run /sethome in the same Feishu DM at least 4 times over the past week (2026-04-20, 04-23, 04-27, 04-28) — every single time it prompts again on the next restart. Cron jobs and cross-platform messages never reach Feishu.

Root Cause

Root cause (two bugs)

Fix Action

Workaround

Manually append to ~/.hermes/.env:

FEISHU_HOME_CHANNEL=oc_your_chat_id_here

Then restart gateway. This works because the startup code path reads from env directly.

PR fix notes

PR #16870: fix(feishu): persist /sethome home channel to .env and load on startup

Description (problem / solution / changelog)

Problem

Feishu /sethome appeared to succeed but the home channel was never persisted. After every gateway restart, users were prompted to run /sethome again.

Root Cause

  1. _handle_set_home_command in gateway/run.py wrote to config.yaml as a top-level key, but load_gateway_config() does not consume top-level {PLATFORM}_HOME_CHANNEL keys.
  2. gateway/config.py lacked a yaml→env mapping for Feishu, so even if the YAML had the value, it was never injected into os.environ.

Solution

  • Write the home channel to .env via save_env_value() (the same helper used by the setup wizard), which atomically updates the file and the current process environment.
  • Add Feishu yaml→env mapping in gateway/config.py for backward compatibility.
  • Add FEISHU_HOME_CHANNEL and FEISHU_HOME_CHANNEL_NAME to _EXTRA_ENV_KEYS so they are treated as managed env vars.

Files Changed

  • gateway/run.py
  • gateway/config.py
  • hermes_cli/config.py

Fixes #16806

Changed files

  • gateway/config.py (modified, +8/-0)
  • gateway/run.py (modified, +3/-11)
  • hermes_cli/config.py (modified, +1/-0)

PR #16900: fix(gateway): persist /sethome home channel to .env across all platforms

Description (problem / solution / changelog)

Summary

/sethome now persists across gateway restarts on every platform — not just Feishu. Previously it wrote {PLATFORM}_HOME_CHANNEL as a top-level key into config.yaml, but load_gateway_config() only reads home channels from env vars, so the setting was silently dropped on every restart.

Root cause: _handle_set_home_command used a bespoke YAML write path that nothing reads. Since the handler builds the env key from platform_name.upper(), switching it to save_env_value() (which writes .env and updates os.environ atomically) fixes /sethome for every platform at once.

Changes

  • gateway/run.py: replace YAML write with save_env_value(env_key, chat_id)
  • hermes_cli/config.py: widen _EXTRA_ENV_KEYS so every platform's HOME_CHANNEL + HOME_CHANNEL_NAME is treated as a managed env var (SIGNAL, SLACK, SMS, DINGTALK, BLUEBUBBLES, FEISHU, WECOM, YUANBAO, plus missing *_NAME variants for DISCORD/TELEGRAM/MATTERMOST)
  • scripts/release.py: AUTHOR_MAP entry for @ztexydt-cqh

Validation

BeforeAfter
/sethome on Feishulost on restartpersists via .env
/sethome on Slack/SMS/Dingtalk/etc.lost on restartpersists via .env
Managed-env parityFeishu, Slack, SMS, etc. not in _EXTRA_ENV_KEYSall platforms covered

E2E: wrote FEISHU/SLACK/SMS home channels via save_env_value(), purged os.environ, reloaded from .env, confirmed load_gateway_config() reconstructs HomeChannel(chat_id=...) correctly for each. Targeted tests: 202 passed.

Credit

Cherry-picked from #16870 by @ztexydt-cqh — their gateway/run.py fix was the core insight; authorship preserved. Dropped the Feishu-only config.yaml → env mapping since no other platform offers that path, and widened _EXTRA_ENV_KEYS for cross-platform parity.

Closes #16806

Changed files

  • gateway/run.py (modified, +3/-11)
  • hermes_cli/config.py (modified, +11/-2)
  • scripts/release.py (modified, +1/-0)

Code Example

env_key = f"{platform_name.upper()}_HOME_CHANNEL"
config_path = _hermes_home / 'config.yaml'
user_config = {}
if config_path.exists():
    with open(config_path, encoding="utf-8") as f:
        user_config = yaml.safe_load(f) or {}
user_config[env_key] = chat_id
atomic_yaml_write(config_path, user_config)

---

$ grep -i "home\|feishu" ~/.hermes/config.yaml
# (no output — the key is not present)

---

2026-04-20 17:10:08 [Feishu] Inbound dm message ... text='/sethome'
2026-04-23 11:09:37 [Feishu] Inbound dm message ... text='/sethome'
2026-04-27 18:48:59 [Feishu] Inbound dm message ... text='/sethome'

---

# gateway/config.py, line ~1170
feishu_home = os.getenv("FEISHU_HOME_CHANNEL")
if feishu_home:
    config.platforms[Platform.FEISHU].home_channel = HomeChannel(...)

---

FEISHU_HOME_CHANNEL=oc_your_chat_id_here

---

feishu_cfg = yaml_cfg.get("feishu", {})
if isinstance(feishu_cfg, dict):
    if "home_channel" in feishu_cfg and not os.getenv("FEISHU_HOME_CHANNEL"):
        os.environ["FEISHU_HOME_CHANNEL"] = str(feishu_cfg["home_channel"])
RAW_BUFFERClick to expand / collapse

/sethome on Feishu silently fails: nothing is persisted, prompt returns every startup

Summary

Running /sethome in a Feishu DM appears to succeed (the command returns the confirmation message), but the home channel is not actually persisted. After every gateway restart, Hermes prompts 📬 No home channel is set for Feishu. Type /sethome to make this chat your home channel... again.

I've run /sethome in the same Feishu DM at least 4 times over the past week (2026-04-20, 04-23, 04-27, 04-28) — every single time it prompts again on the next restart. Cron jobs and cross-platform messages never reach Feishu.

Environment

  • Hermes version: 0.10.0 (reproduces on current main as well — I verified both code paths below)
  • Platform: Feishu (self-hosted, websocket mode)
  • OS: Ubuntu 25.10
  • Python: venv managed

Root cause (two bugs)

Bug 1 — /sethome handler writes to config.yaml, but nothing actually lands there

gateway/run.py::_handle_sethome_command (line ~6379 on main, same on 0.10.0) tries to save via:

env_key = f"{platform_name.upper()}_HOME_CHANNEL"
config_path = _hermes_home / 'config.yaml'
user_config = {}
if config_path.exists():
    with open(config_path, encoding="utf-8") as f:
        user_config = yaml.safe_load(f) or {}
user_config[env_key] = chat_id
atomic_yaml_write(config_path, user_config)

The env_key is "FEISHU_HOME_CHANNEL" (ALL_CAPS). After four /sethome calls on my install, inspecting ~/.hermes/config.yaml:

$ grep -i "home\|feishu" ~/.hermes/config.yaml
# (no output — the key is not present)

The file contains only model/memory/compression/session_reset/display sections — no top-level FEISHU_HOME_CHANNEL key was written. (The existing config.yaml is a commented template shipped with the install; it may be that atomic_yaml_write is not re-serializing the merged dict, or comments/structure are getting in the way — I haven't dug further, but the observed outcome is: nothing is persisted.)

Logs confirm the inbound command fired every time:

2026-04-20 17:10:08 [Feishu] Inbound dm message ... text='/sethome'
2026-04-23 11:09:37 [Feishu] Inbound dm message ... text='/sethome'
2026-04-27 18:48:59 [Feishu] Inbound dm message ... text='/sethome'

Bug 2 — Even if config.yaml did contain FEISHU_HOME_CHANNEL, startup would ignore it

gateway/config.py applies yaml_cfg → os.environ for several platforms (dingtalk, matrix, etc.) but has no such mapping for Feishu. Feishu's home channel is only read from the environment:

# gateway/config.py, line ~1170
feishu_home = os.getenv("FEISHU_HOME_CHANNEL")
if feishu_home:
    config.platforms[Platform.FEISHU].home_channel = HomeChannel(...)

So the /sethome handler and the startup loader are out of sync for Feishu: the handler writes to yaml, but the loader only reads from env. Even if Bug 1 is fixed, Bug 2 means nothing takes effect until the user manually sets FEISHU_HOME_CHANNEL in ~/.hermes/.env.

(This probably also affects other platforms where the yaml→env mapping is missing — I only verified Feishu.)

Reproduction

  1. Fresh Hermes install with Feishu DM configured.
  2. In Feishu DM, send /sethome. Observe ✅ Home channel set to ... confirmation.
  3. systemctl --user restart hermes-gateway (or any restart).
  4. Send any message in the DM. Observe the prompt: 📬 No home channel is set for Feishu. Type /sethome... returns.
  5. grep FEISHU_HOME_CHANNEL ~/.hermes/config.yaml — empty.
  6. grep FEISHU_HOME_CHANNEL ~/.hermes/.env — empty.

Workaround

Manually append to ~/.hermes/.env:

FEISHU_HOME_CHANNEL=oc_your_chat_id_here

Then restart gateway. This works because the startup code path reads from env directly.

Suggested fix

Two orthogonal fixes:

Fix A — /sethome should write to .env (or a dedicated state file), not config.yaml.

config.yaml is a user-authored template with comments and structure; writing runtime state into it is fragile (and evidently broken). .env is the canonical env-var source and already is the source of truth for startup. A save_env_value("FEISHU_HOME_CHANNEL", chat_id) call (Hermes already has this helper — it's used in the setup wizard at hermes_cli/gateway.py:2990) would work for all platforms uniformly.

Fix B — Add yaml→env mapping for Feishu (and audit others) in gateway/config.py.

If keeping yaml as a valid source, add the same pattern that exists for matrix/dingtalk:

feishu_cfg = yaml_cfg.get("feishu", {})
if isinstance(feishu_cfg, dict):
    if "home_channel" in feishu_cfg and not os.getenv("FEISHU_HOME_CHANNEL"):
        os.environ["FEISHU_HOME_CHANNEL"] = str(feishu_cfg["home_channel"])

Fix A alone would resolve the immediate user-visible bug. Both together would make the config story consistent.

Additional context

Happy to send a PR for Fix A if maintainers agree it's the right direction. Let me know preferred approach (env vs yaml vs new state file).

extent analysis

TL;DR

The most likely fix for the /sethome command issue on Feishu is to modify the command handler to write to the .env file instead of config.yaml, ensuring consistency with the startup code path.

Guidance

  1. Verify the issue: Confirm that the config.yaml file does not contain the FEISHU_HOME_CHANNEL key after running the /sethome command.
  2. Apply Fix A: Modify the /sethome command handler to write to the .env file using the save_env_value helper function, ensuring that the FEISHU_HOME_CHANNEL environment variable is set correctly.
  3. Test the workaround: Manually append the FEISHU_HOME_CHANNEL variable to the .env file and restart the gateway to verify that the issue is resolved.
  4. Consider Fix B: Add a yaml→env mapping for Feishu in gateway/config.py to ensure consistency with other platforms, if maintaining yaml as a valid source is desired.

Example

# Modified /sethome command handler
save_env_value("FEISHU_HOME_CHANNEL", chat_id)

Notes

The provided fixes assume that the issue is specific to the Feishu platform and may not apply to other platforms. Additionally, the choice between using the .env file or config.yaml as the source of truth for runtime state should be considered carefully to ensure consistency across the application.

Recommendation

Apply Fix A, as it directly addresses the issue and ensures consistency with the startup code path. This approach is also preferred as it uses the existing save_env_value helper function and avoids modifying the config.yaml file, which is a user-authored template.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING