diff --git a/index.ts b/index.ts index 212dede..a355e60 100644 --- a/index.ts +++ b/index.ts @@ -2785,6 +2785,21 @@ const memoryLanceDBProPlugin = { return; } + // Skip self-improvement note on Discord channel (non-thread) resets + // to avoid contributing to the post-reset startup race on Discord channels. + // Discord thread resets are handled separately by the OpenClaw core's + // postRotationStartupUntilMs mechanism (PR #49001). + // Note: Provider lives in sessionEntry.Provider; MessageThreadId lives in + // sessionEntry.threadId (populated from ctx.MessageThreadId at session creation). + const provider = contextForLog.sessionEntry?.Provider ?? ""; + const threadId = contextForLog.sessionEntry?.threadId; + if (provider === "discord" && (threadId == null || threadId === "")) { + api.logger.info( + `self-improvement: command:${action} skipped on Discord channel (non-thread) reset to avoid startup race; use /new in thread or restart gateway if startup is incomplete` + ); + return; + } + const exists = event.messages.some((m: unknown) => typeof m === "string" && m.includes(SELF_IMPROVEMENT_NOTE_PREFIX)); if (exists) { api.logger.info(`self-improvement: command:${action} note already present; skip duplicate inject`);