hermes - ✅(Solved) Fix IRC default port sticks to 6697 even for non-tls usage. [1 pull requests, 1 comments, 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#20161Fetched 2026-05-06 06:38:18
View on GitHub
Comments
1
Participants
1
Timeline
5
Reactions
0
Participants
Timeline (top)
labeled ×3commented ×1cross-referenced ×1

The IRC platform adapter in plugins/platforms/irc/adapter.py uses incorrect default port logic. Even when use_tls: false (or when connecting to a local IRC server on plain port 6667), the adapter consistently defaults to port 6697 (SSL port) because the use_tls variable is evaluated after the port is set.

Root Cause

In plugins/platforms/irc/adapter.py around lines 112-133:

Current buggy code:

def __init__(self, config, **kwargs):
    platform = Platform("irc")
    super().__init__(config=config, platform=platform)

    extra = getattr(config, "extra", {}) or {}

    # Connection settings (env vars override config.yaml)
    self.server = os.getenv("IRC_SERVER") or extra.get("server", "")
    
    # BUG: Port is set BEFORE use_tls is evaluated
    self.port = int(os.getenv("IRC_PORT") or extra.get("port", 6697))
    
    self.nickname = os.getenv("IRC_NICKNAME") or extra.get("nickname", "hermes-bot")
    self.channel = os.getenv("IRC_CHANNEL") or extra.get("channel", "")
    
    # use_tls evaluated TOO LATE - after port is already set
    self.use_tls = (
        os.getenv("IRC_USE_TLS", "").lower() in ("1", "true", "yes")
        if os.getenv("IRC_USE_TLS")
        else extra.get("use_tls", True)
    )

The default 6697 at line ~119 doesn't respect the use_tls variable. While line ~578 has the correct logic:

default_port = "6697" if use_tls else "6667"

This is never used in the main __init__ port assignment.

Fix Action

Fixed

PR fix notes

PR #20190: fix(irc): use correct default port based on use_tls setting

Description (problem / solution / changelog)

Summary

Fixes #20161 — IRC adapter defaults to port 6697 even when use_tls: false.

Root Cause

In plugins/platforms/irc/adapter.py, self.port was assigned with a hardcoded default of 6697 before self.use_tls was evaluated. This meant the TLS setting had no effect on the default port.

Fix

Reorder initialization so use_tls is evaluated first, then derive the default port:

  • use_tls=True → default port 6697
  • use_tls=False → default port 6667

Explicit port in config or IRC_PORT env var still takes precedence.

Changes

  • plugins/platforms/irc/adapter.py: Move use_tls evaluation before port assignment; compute default_port dynamically.

Testing

  • All 64 existing IRC-related tests pass (1 pre-existing unrelated failure in test_setup_irc — stdin capture issue on main).
  • Manual verification: with use_tls: false and no explicit port, adapter now correctly uses 6667.

Changed files

  • plugins/platforms/irc/adapter.py (modified, +4/-3)

Code Example

gateway:
  platforms:
    irc:
      enabled: true
      extra:
        server: 127.0.0.1
        port: 6667
        nickname: hermes
        channel: "#test"
        use_tls: false

---

extra:
  server: 127.0.0.1
  # port not specified
  use_tls: false  # <-- explicitly false

---

def __init__(self, config, **kwargs):
    platform = Platform("irc")
    super().__init__(config=config, platform=platform)

    extra = getattr(config, "extra", {}) or {}

    # Connection settings (env vars override config.yaml)
    self.server = os.getenv("IRC_SERVER") or extra.get("server", "")
    
    # BUG: Port is set BEFORE use_tls is evaluated
    self.port = int(os.getenv("IRC_PORT") or extra.get("port", 6697))
    
    self.nickname = os.getenv("IRC_NICKNAME") or extra.get("nickname", "hermes-bot")
    self.channel = os.getenv("IRC_CHANNEL") or extra.get("channel", "")
    
    # use_tls evaluated TOO LATE - after port is already set
    self.use_tls = (
        os.getenv("IRC_USE_TLS", "").lower() in ("1", "true", "yes")
        if os.getenv("IRC_USE_TLS")
        else extra.get("use_tls", True)
    )

---

default_port = "6697" if use_tls else "6667"

---

def __init__(self, config, **kwargs):
    platform = Platform("irc")
    super().__init__(config=config, platform=platform)

    extra = getattr(config, "extra", {}) or {}

    self.server = os.getenv("IRC_SERVER") or extra.get("server", "")
    self.nickname = os.getenv("IRC_NICKNAME") or extra.get("nickname", "hermes-bot")
    self.channel = os.getenv("IRC_CHANNEL") or extra.get("channel", "")
    
    # Fix: Evaluate use_tls BEFORE port
    self.use_tls = (
        os.getenv("IRC_USE_TLS", "").lower() in ("1", "true", "yes")
        if os.getenv("IRC_USE_TLS")
        else extra.get("use_tls", True)
    )
    
    # Fix: Port now respects use_tls default
    self.port = (
        int(os.getenv("IRC_PORT"))  # env var
        or (
            int(extra.get("port"))  # config
            if extra.get("port")
            else (6697 if self.use_tls else 6667)  # correct default
        )
    )
    
    self.server_password = os.getenv("IRC_SERVER_PASSWORD") or extra.get("server_password", "")
    self.nickserv_password = os.getenv("IRC_NICKSERV_PASSWORD") or extra.get("nickserv_password", "")
    # ... rest of initialization
RAW_BUFFERClick to expand / collapse

[Bug] IRC Adapter Defaults to Wrong Port (6697 instead of 6667)

Summary

The IRC platform adapter in plugins/platforms/irc/adapter.py uses incorrect default port logic. Even when use_tls: false (or when connecting to a local IRC server on plain port 6667), the adapter consistently defaults to port 6697 (SSL port) because the use_tls variable is evaluated after the port is set.

Steps to Reproduce

  1. Configure IRC adapter with:
gateway:
  platforms:
    irc:
      enabled: true
      extra:
        server: 127.0.0.1
        port: 6667
        nickname: hermes
        channel: "#test"
        use_tls: false
  1. Start the gateway: hermes gateway run

  2. Observe: Gateway attempts to connect to 127.0.0.1:6697 instead of 127.0.0.1:6667

OR without explicit port (relying on default):

extra:
  server: 127.0.0.1
  # port not specified
  use_tls: false  # <-- explicitly false

Gateway still tries port 6697 instead of 6667.

Expected Behavior

When use_tls: false, default port should be 6667 (IRC standard non-SSL port).

Actual Behavior

Gateway always uses port 6697 regardless of TLS setting, unless explicitly overridden.

Root Cause

In plugins/platforms/irc/adapter.py around lines 112-133:

Current buggy code:

def __init__(self, config, **kwargs):
    platform = Platform("irc")
    super().__init__(config=config, platform=platform)

    extra = getattr(config, "extra", {}) or {}

    # Connection settings (env vars override config.yaml)
    self.server = os.getenv("IRC_SERVER") or extra.get("server", "")
    
    # BUG: Port is set BEFORE use_tls is evaluated
    self.port = int(os.getenv("IRC_PORT") or extra.get("port", 6697))
    
    self.nickname = os.getenv("IRC_NICKNAME") or extra.get("nickname", "hermes-bot")
    self.channel = os.getenv("IRC_CHANNEL") or extra.get("channel", "")
    
    # use_tls evaluated TOO LATE - after port is already set
    self.use_tls = (
        os.getenv("IRC_USE_TLS", "").lower() in ("1", "true", "yes")
        if os.getenv("IRC_USE_TLS")
        else extra.get("use_tls", True)
    )

The default 6697 at line ~119 doesn't respect the use_tls variable. While line ~578 has the correct logic:

default_port = "6697" if use_tls else "6667"

This is never used in the main __init__ port assignment.

Proposed Fix

Reorder initialization to evaluate use_tls BEFORE port assignment:

def __init__(self, config, **kwargs):
    platform = Platform("irc")
    super().__init__(config=config, platform=platform)

    extra = getattr(config, "extra", {}) or {}

    self.server = os.getenv("IRC_SERVER") or extra.get("server", "")
    self.nickname = os.getenv("IRC_NICKNAME") or extra.get("nickname", "hermes-bot")
    self.channel = os.getenv("IRC_CHANNEL") or extra.get("channel", "")
    
    # Fix: Evaluate use_tls BEFORE port
    self.use_tls = (
        os.getenv("IRC_USE_TLS", "").lower() in ("1", "true", "yes")
        if os.getenv("IRC_USE_TLS")
        else extra.get("use_tls", True)
    )
    
    # Fix: Port now respects use_tls default
    self.port = (
        int(os.getenv("IRC_PORT"))  # env var
        or (
            int(extra.get("port"))  # config
            if extra.get("port")
            else (6697 if self.use_tls else 6667)  # correct default
        )
    )
    
    self.server_password = os.getenv("IRC_SERVER_PASSWORD") or extra.get("server_password", "")
    self.nickserv_password = os.getenv("IRC_NICKSERV_PASSWORD") or extra.get("nickserv_password", "")
    # ... rest of initialization

Environment

  • Hermes Agent: Latest from nousresearch/hermes-agent repo
  • Platform: Ubuntu 24.04 (Linux)

Additional Notes

This regression appears to have been introduced when the use_tls default was changed to True (line 122 in current code), but the port variable was never updated to reflect this change dynamically.

Local/self-hosted IRC servers typically run on:

  • Port 6667 (plain/text)
  • Port 6697 (SSL/TLS encrypted)

The adapter should automatically choose the correct port based on whether TLS is enabled, rather than requiring manual port specification every time.

Testing

After fix, test cases should verify:

  1. use_tls: false without port specified → connects to 6667
  2. use_tls: true without port specified → connects to 6697
  3. Explicit port always overrides (regardless of use_tls)
  4. Environment variables still work correctly

extent analysis

TL;DR

Reorder the initialization in adapter.py to evaluate use_tls before port assignment to fix the IRC adapter defaulting to the wrong port.

Guidance

  • Evaluate use_tls before assigning the port in __init__ method of adapter.py.
  • Use the proposed fix code to update the port assignment logic, making it respect the use_tls variable.
  • Test the fix with the provided test cases to ensure correct behavior for different use_tls settings and port specifications.
  • Verify that environment variables still work correctly after the fix.

Example

The proposed fix code snippet demonstrates the corrected initialization order and port assignment logic:

self.use_tls = (
    os.getenv("IRC_USE_TLS", "").lower() in ("1", "true", "yes")
    if os.getenv("IRC_USE_TLS")
    else extra.get("use_tls", True)
)
self.port = (
    int(os.getenv("IRC_PORT"))  
    or (
        int(extra.get("port"))  
        if extra.get("port")
        else (6697 if self.use_tls else 6667)  
    )
)

Notes

This fix assumes that the use_tls variable is the only factor determining the default port. If other factors are involved, additional logic may be required.

Recommendation

Apply the proposed workaround by reordering the initialization in adapter.py to evaluate use_tls before port assignment, as this directly addresses the identified issue and ensures the correct default port is used based on the use_tls setting.

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