Merge pull request #1287 from NousResearch/hermes/hermes-cc060dd9

fix(gateway): avoid slash-command crash with GatewayConfig
This commit is contained in:
Teknium 2026-03-14 04:13:56 -07:00 committed by GitHub
commit 02752c83b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 79 additions and 3 deletions

View file

@ -151,6 +151,9 @@ class GatewayConfig:
# Reset trigger commands
reset_triggers: List[str] = field(default_factory=lambda: ["/new", "/reset"])
# User-defined quick commands (slash commands that bypass the agent loop)
quick_commands: Dict[str, Any] = field(default_factory=dict)
# Storage paths
sessions_dir: Path = field(default_factory=lambda: get_hermes_home() / "sessions")
@ -218,6 +221,7 @@ class GatewayConfig:
p.value: v.to_dict() for p, v in self.reset_by_platform.items()
},
"reset_triggers": self.reset_triggers,
"quick_commands": self.quick_commands,
"sessions_dir": str(self.sessions_dir),
"always_log_local": self.always_log_local,
}
@ -252,12 +256,17 @@ class GatewayConfig:
if "sessions_dir" in data:
sessions_dir = Path(data["sessions_dir"])
quick_commands = data.get("quick_commands", {})
if not isinstance(quick_commands, dict):
quick_commands = {}
return cls(
platforms=platforms,
default_reset_policy=default_policy,
reset_by_type=reset_by_type,
reset_by_platform=reset_by_platform,
reset_triggers=data.get("reset_triggers", ["/new", "/reset"]),
quick_commands=quick_commands,
sessions_dir=sessions_dir,
always_log_local=data.get("always_log_local", True),
)
@ -299,6 +308,16 @@ def load_gateway_config() -> GatewayConfig:
if sr and isinstance(sr, dict):
config.default_reset_policy = SessionResetPolicy.from_dict(sr)
# Bridge quick commands from config.yaml into gateway runtime config.
# config.yaml is the user-facing config source, so when present it
# should override gateway.json for this setting.
qc = yaml_cfg.get("quick_commands")
if qc is not None:
if isinstance(qc, dict):
config.quick_commands = qc
else:
logger.warning("Ignoring invalid quick_commands in config.yaml (expected mapping, got %s)", type(qc).__name__)
# Bridge discord settings from config.yaml to env vars
# (env vars take precedence — only set if not already defined)
discord_cfg = yaml_cfg.get("discord", {})

View file

@ -1023,7 +1023,12 @@ class GatewayRunner:
# User-defined quick commands (bypass agent loop, no LLM call)
if command:
quick_commands = self.config.get("quick_commands", {})
if isinstance(self.config, dict):
quick_commands = self.config.get("quick_commands", {}) or {}
else:
quick_commands = getattr(self.config, "quick_commands", {}) or {}
if not isinstance(quick_commands, dict):
quick_commands = {}
if command in quick_commands:
qcmd = quick_commands[command]
if qcmd.get("type") == "exec":