diff --git a/plugin/index.ts b/plugin/index.ts index 1de1e3a..ddbb311 100644 --- a/plugin/index.ts +++ b/plugin/index.ts @@ -805,7 +805,8 @@ export default { // Handle NO_REPLY detection before message write // This is where we detect if agent output is NO_REPLY and handle turn advancement - api.on("before_message_write", async (event, ctx) => { + // NOTE: This hook is synchronous, do not use async/await + api.on("before_message_write", (event, ctx) => { try { const key = ctx.sessionKey; const channelId = ctx.channelId as string | undefined; @@ -859,12 +860,14 @@ export default { return; } - // Trigger moderator handoff message + // Trigger moderator handoff message (fire-and-forget, don't await) if (live.moderatorBotToken) { const nextUserId = resolveDiscordUserId(api, nextSpeaker); if (nextUserId) { const handoffMsg = `轮到(<@${nextUserId}>)了,如果没有想说的请直接回复NO_REPLY`; - sendModeratorMessage(live.moderatorBotToken, channelId, handoffMsg, api.logger); + void sendModeratorMessage(live.moderatorBotToken, channelId, handoffMsg, api.logger).catch((err) => { + api.logger.warn(`whispergate: before_message_write handoff failed: ${String(err)}`); + }); } else { api.logger.warn(`whispergate: cannot resolve Discord userId for next speaker accountId=${nextSpeaker}`); }