hermes - ✅(Solved) Fix [Bug]: config.yaml settings override .env settings, despite doc says the opposite [1 pull requests, 1 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#13685Fetched 2026-04-22 08:04:44
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
cross-referenced ×1subscribed ×1

Fix Action

Fixed

PR fix notes

PR #13732: fix(discord): honor documented env-wins-over-config precedence for require_mention/free_response_channels

Description (problem / solution / changelog)

Summary

Fixes #13685. The Discord channel docs state:

Config.yaml settings are applied as defaults — if the equivalent env var is already set, the env var wins.

But `_discord_require_mention` and `_discord_free_response_channels` in `gateway/platforms/discord.py` checked `config.extra` first and only fell back to the env var when config was unset — inverting the documented contract for the two most commonly configured Discord gating fields. Since `require_mention: true` is the default in a fresh `config.yaml`, the env var never wins in practice.

Fix

Swap the order in both helpers: env var read first, config.extra as fallback, hardcoded default last. An empty-string env value is treated as not actively set so unset-vs-empty remains distinguishable (an empty string does not mask a non-empty config list).

Test

Added 6 regression tests in `TestDiscordEnvPrecedenceOverConfig`:

  • env TRUE overrides config FALSE for `require_mention` (and vice versa)
  • config value used when env unset
  • default TRUE when neither set
  • env list overrides config list for `free_response_channels`
  • empty env string falls through to config (unset-vs-empty guard)

All 6 new tests pass locally. Pre-existing async tests in the same file fail due to missing `pytest-asyncio` in the local venv — unrelated to this change (same 20 failures present on `main` without my patch).

Scope

2 private methods in 1 adapter. Pure precedence swap — no new capability. Rule out: I checked `PR #9837` which touches `reply_to_mode` (different field), not a rival for these two fields.

Closes #13685.

Changed files

  • gateway/platforms/discord.py (modified, +21/-6)
  • tests/gateway/test_discord_free_response.py (modified, +38/-0)

Code Example

def _discord_require_mention(self) -> bool:
        """Return whether Discord channel messages require a bot mention."""
        configured = self.config.extra.get("require_mention")
        if configured is not None:
            if isinstance(configured, str):
                return configured.lower() not in ("false", "0", "no", "off")
            return bool(configured)
        return os.getenv("DISCORD_REQUIRE_MENTION", "true").lower() not in ("false", "0", "no", "off")
RAW_BUFFERClick to expand / collapse

In the documentation for Discord channel, it is written:

Config.yaml settings are applied as defaults — if the equivalent env var is already set, the env var wins.

This is not true for at least two values:

  • discord.free_response_channels
  • discord.require_mention Where, if config.yaml has the key, the value in the .env file is ignored.

Looking at the code in discord.py, line 2480 :

    def _discord_require_mention(self) -> bool:
        """Return whether Discord channel messages require a bot mention."""
        configured = self.config.extra.get("require_mention")
        if configured is not None:
            if isinstance(configured, str):
                return configured.lower() not in ("false", "0", "no", "off")
            return bool(configured)
        return os.getenv("DISCORD_REQUIRE_MENTION", "true").lower() not in ("false", "0", "no", "off")

If the configuration has the value (which is the default in a fresh new installation), the value in .env file is not picked up.

Ideally, or the code is fixed to account first env values, and the config values, or the documentation is fixed to reflect that confgiration values has priority over env values.

extent analysis

TL;DR

The issue can be resolved by updating the code to prioritize environment variables over configuration values or by updating the documentation to reflect the current behavior.

Guidance

  • Review the code in discord.py to understand how configuration values and environment variables are currently being handled.
  • Consider updating the code to check for environment variables before defaulting to configuration values, as shown in the example below.
  • Verify that the updated code correctly prioritizes environment variables over configuration values.
  • If updating the code is not feasible, update the documentation to reflect the current behavior, where configuration values take priority over environment variables.

Example

def _discord_require_mention(self) -> bool:
    """Return whether Discord channel messages require a bot mention."""
    env_var = os.getenv("DISCORD_REQUIRE_MENTION")
    if env_var is not None:
        return env_var.lower() not in ("false", "0", "no", "off")
    configured = self.config.extra.get("require_mention")
    if configured is not None:
        if isinstance(configured, str):
            return configured.lower() not in ("false", "0", "no", "off")
        return bool(configured)
    return True

Notes

The provided code snippet only shows the _discord_require_mention method, and it is unclear if the same issue affects other configuration values. A thorough review of the code is necessary to ensure that all configuration values are handled correctly.

Recommendation

Apply workaround: Update the documentation to reflect the current behavior, where configuration values take priority over environment variables, until the code can be updated to correctly prioritize environment variables. This ensures that users are aware of the current behavior and can plan accordingly.

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

hermes - ✅(Solved) Fix [Bug]: config.yaml settings override .env settings, despite doc says the opposite [1 pull requests, 1 participants]