Skip to content

Commit 3367a5f

Browse files
ContributorMarcusTseng
authored andcommitted
fix(self-improvement): skip note inject on Discord channel /new to avoid hook interference
Skip self-improvement note injection on Discord channel (non-thread) resets. The appendSelfImprovementNote hook was push()ing synchronously into event.messages before the first agent turn ran, which contributed to the post-reset startup race described in openclaw/openclaw#46941. Discord channel resets are guarded by checking Provider=discord && (MessageThreadId == null or empty). Thread resets and non-Discord surfaces are unaffected. Ref: openclaw/openclaw#46941 (root cause: /new re-fires command:new hooks) Ref: openclaw/openclaw#49001 (thread-only post-rotation window)
1 parent 5c477c1 commit 3367a5f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,6 +2785,19 @@ const memoryLanceDBProPlugin = {
27852785
return;
27862786
}
27872787

2788+
// Skip self-improvement note on Discord channel (non-thread) resets
2789+
// to avoid contributing to the post-reset startup race on Discord channels.
2790+
// Discord thread resets are handled separately by the OpenClaw core's
2791+
// postRotationStartupUntilMs mechanism (PR #49001).
2792+
const provider = typeof contextForLog.Provider === "string" ? contextForLog.Provider : "";
2793+
const messageThreadId = contextForLog.MessageThreadId;
2794+
if (provider === "discord" && (messageThreadId == null || messageThreadId === "")) {
2795+
api.logger.info(
2796+
`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`
2797+
);
2798+
return;
2799+
}
2800+
27882801
const exists = event.messages.some((m: unknown) => typeof m === "string" && m.includes(SELF_IMPROVEMENT_NOTE_PREFIX));
27892802
if (exists) {
27902803
api.logger.info(`self-improvement: command:${action} note already present; skip duplicate inject`);

0 commit comments

Comments
 (0)