feat: memory reflection updates (#906)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2026-02-10 18:25:49 -08:00
committed by GitHub
parent d1a6eeb40a
commit a69541004b
6 changed files with 313 additions and 2 deletions

View File

@@ -7505,8 +7505,10 @@ ${SYSTEM_REMINDER_CLOSE}
}
// Build memory reminder if interval is set and we've reached the Nth turn
// When MemFS is enabled, this returns a reflection reminder instead
const memoryReminderContent = await buildMemoryReminder(
turnCountRef.current,
agentId,
);
// Increment turn count for next iteration

View File

@@ -2,6 +2,7 @@
// Handles periodic memory reminder logic and preference parsing
import { settingsManager } from "../../settings-manager";
import { debugLog } from "../../utils/debug";
// Memory reminder interval presets
const MEMORY_INTERVAL_FREQUENT = 5;
@@ -27,14 +28,39 @@ function getMemoryInterval(): number | null {
}
/**
* Build a memory check reminder if the turn count matches the interval
* Build a memory check reminder if the turn count matches the interval.
*
* - MemFS enabled: returns MEMORY_REFLECTION_REMINDER
* (instructs agent to launch background reflection Task)
* - MemFS disabled: returns MEMORY_CHECK_REMINDER
* (existing behavior, agent updates memory inline)
*
* @param turnCount - Current conversation turn count
* @param agentId - Current agent ID (needed to check MemFS status)
* @returns Promise resolving to the reminder string (empty if not applicable)
*/
export async function buildMemoryReminder(turnCount: number): Promise<string> {
export async function buildMemoryReminder(
turnCount: number,
agentId: string,
): Promise<string> {
const memoryInterval = getMemoryInterval();
if (memoryInterval && turnCount > 0 && turnCount % memoryInterval === 0) {
if (settingsManager.isMemfsEnabled(agentId)) {
debugLog(
"memory",
`Reflection reminder fired (turn ${turnCount}, agent ${agentId})`,
);
const { MEMORY_REFLECTION_REMINDER } = await import(
"../../agent/promptAssets.js"
);
return MEMORY_REFLECTION_REMINDER;
}
debugLog(
"memory",
`Memory check reminder fired (turn ${turnCount}, agent ${agentId})`,
);
const { MEMORY_CHECK_REMINDER } = await import(
"../../agent/promptAssets.js"
);