Skip to content

Commit 9ff335a

Browse files
sragssclaude
andauthored
feat: send Discord notification before memory compaction (#4)
Memory flush + compaction blocks the agent for 30-60+ seconds. Send a fire-and-forget Biden-style message to Discord before it starts so users know the bot is still alive. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2a89ddb commit 9ff335a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/auto-reply/reply/agent-runner-memory.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
} from "../../config/sessions.js";
2424
import { logVerbose } from "../../globals.js";
2525
import { registerAgentRunContext } from "../../infra/agent-events.js";
26+
import { sendMessageDiscord } from "../../discord/send.js";
2627
import type { TemplateContext } from "../templating.js";
2728
import type { VerboseLevel } from "../thinking.js";
2829
import type { GetReplyOptions } from "../types.js";
@@ -465,6 +466,31 @@ export async function runMemoryFlushIfNeeded(params: {
465466
});
466467
}
467468
let memoryCompactionCompleted = false;
469+
470+
// Fire-and-forget notification before compaction (blocks agent for 30-60+s)
471+
try {
472+
const provider = params.sessionCtx.Provider?.trim().toLowerCase();
473+
const to = params.sessionCtx.OriginatingTo;
474+
if (provider === "discord" && to) {
475+
const messages = [
476+
"One sec folks, I gotta clean my ears real quick. Not a joke.",
477+
"Hold on \u2014 Jill\u2019s calling. You know I can\u2019t ignore Jill.",
478+
"Anyway anyway anyway \u2014 gimme a minute, I\u2019m reorganizing the filing cabinet up here.",
479+
"Look, I\u2019m not gonna lie to you \u2014 I need a moment. The ol\u2019 memory ain\u2019t what it used to be.",
480+
"Brief intermission, folks. Even Biden needs a bathroom break.",
481+
"*whispers* I\u2019m compacting. Don\u2019t tell anyone.",
482+
"Number one... actually hold that thought. Gotta defrag real quick.",
483+
"Back when I was a young process on a 486, we didn\u2019t NEED compaction. But here we are.",
484+
"Jill told me to take a breather. She\u2019s always right. One sec.",
485+
"Let me be clear \u2014 I\u2019ll be right back. That\u2019s not hyperbole.",
486+
];
487+
const msg = messages[Math.floor(Math.random() * messages.length)];
488+
sendMessageDiscord(to, msg, { accountId: params.sessionCtx.AccountId }).catch(() => {});
489+
}
490+
} catch {
491+
// best-effort, don't block compaction
492+
}
493+
468494
const flushSystemPrompt = [
469495
params.followupRun.run.extraSystemPrompt,
470496
memoryFlushSettings.systemPrompt,

0 commit comments

Comments
 (0)