From e9e78c7bc035d1d30d8352b1f291cd14d9bffeff Mon Sep 17 00:00:00 2001 From: Bartok Moltbot Date: Fri, 27 Feb 2026 03:05:41 -0500 Subject: [PATCH] fix(gateway): Move hooks and pairing_store init to __init__ Fixes #110 The pairing_store and hooks initialization was accidentally placed inside _flush_memories_before_reset() instead of __init__(), causing the gateway to crash on startup with: AttributeError: GatewayRunner object has no attribute hooks This affected fresh installs where the gateway service would fail immediately when calling self.hooks.discover_and_load() in start(). Moved the initialization to the proper location at the end of GatewayRunner.__init__(). --- gateway/run.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gateway/run.py b/gateway/run.py index 3d34aaad8f41..a00f1eeaf537 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -157,6 +157,14 @@ def __init__(self, config: Optional[GatewayConfig] = None): except Exception as e: logger.debug("SQLite session store not available: %s", e) + # DM pairing store for code-based user authorization + from gateway.pairing import PairingStore + self.pairing_store = PairingStore() + + # Event hook system + from gateway.hooks import HookRegistry + self.hooks = HookRegistry() + def _flush_memories_before_reset(self, old_entry): """Prompt the agent to save memories/skills before an auto-reset. @@ -216,14 +224,6 @@ def _flush_memories_before_reset(self, old_entry): logger.info("Pre-reset save completed for session %s", old_entry.session_id) except Exception as e: logger.debug("Pre-reset save failed for session %s: %s", old_entry.session_id, e) - - # DM pairing store for code-based user authorization - from gateway.pairing import PairingStore - self.pairing_store = PairingStore() - - # Event hook system - from gateway.hooks import HookRegistry - self.hooks = HookRegistry() @staticmethod def _load_prefill_messages() -> List[Dict[str, Any]]: