feat: add /remember command for quick memory updates (#179)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2025-12-11 15:13:48 -08:00
committed by GitHub
parent ead4203448
commit 23b335fee7
4 changed files with 112 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ import personaEmptyPrompt from "./prompts/persona_empty.mdx";
import personaKawaiiPrompt from "./prompts/persona_kawaii.mdx"; import personaKawaiiPrompt from "./prompts/persona_kawaii.mdx";
import planModeReminder from "./prompts/plan_mode_reminder.txt"; import planModeReminder from "./prompts/plan_mode_reminder.txt";
import projectPrompt from "./prompts/project.mdx"; import projectPrompt from "./prompts/project.mdx";
import rememberPrompt from "./prompts/remember.md";
import skillCreatorModePrompt from "./prompts/skill_creator_mode.md"; import skillCreatorModePrompt from "./prompts/skill_creator_mode.md";
import skillUnloadReminder from "./prompts/skill_unload_reminder.txt"; import skillUnloadReminder from "./prompts/skill_unload_reminder.txt";
import skillsPrompt from "./prompts/skills.mdx"; import skillsPrompt from "./prompts/skills.mdx";
@@ -25,6 +26,7 @@ export const PLAN_MODE_REMINDER = planModeReminder;
export const SKILL_UNLOAD_REMINDER = skillUnloadReminder; export const SKILL_UNLOAD_REMINDER = skillUnloadReminder;
export const INITIALIZE_PROMPT = initializePrompt; export const INITIALIZE_PROMPT = initializePrompt;
export const SKILL_CREATOR_PROMPT = skillCreatorModePrompt; export const SKILL_CREATOR_PROMPT = skillCreatorModePrompt;
export const REMEMBER_PROMPT = rememberPrompt;
export const MEMORY_PROMPTS: Record<string, string> = { export const MEMORY_PROMPTS: Record<string, string> = {
"persona.mdx": personaPrompt, "persona.mdx": personaPrompt,

View File

@@ -0,0 +1,29 @@
# Memory Request
The user has invoked the `/remember` command, which indicates they want you to commit something to memory.
## What This Means
The user wants you to use your memory tools to remember information from the conversation. This could be:
- **A correction**: "You need to run the linter BEFORE committing" → they want you to remember this workflow
- **A preference**: "I prefer tabs over spaces" → store in the appropriate memory block
- **A fact**: "The API key is stored in .env.local" → project-specific knowledge
- **A rule**: "Never push directly to main" → behavioral guideline
## Your Task
1. **Identify what to remember**: Look at the recent conversation context. What did the user say that they want you to remember? If they provided text after `/remember`, that's what they want remembered. If after analyzing it is still unclear, you can ask the user to clarify or provide more context.
2. **Determine the right memory block**: Use your memory tools to store the information in the appropriate memory block. Different agents may have different configurations of memory blocks. Use your judgement to determine the most appropriate memory block (or blocks) to edit. Consider creating a new block is no relevant block exists.
3. **Confirm the update**: After updating memory, briefly confirm what you remembered and where you stored it.
## Guidelines
- Be concise - distill the information to its essence
- Avoid duplicates - check if similar information already exists
- Match existing formatting of memory blocks (bullets, sections, etc.)
- If unclear what to remember, ask the user to clarify
Remember: Your memory blocks persist across sessions. What you store now will influence your future behavior.

View File

@@ -1673,6 +1673,80 @@ export default function App({
return { submitted: true }; return { submitted: true };
} }
// Special handling for /remember command - remember something from conversation
if (trimmed.startsWith("/remember")) {
const cmdId = uid("cmd");
// Extract optional description after `/remember`
const [, ...rest] = trimmed.split(/\s+/);
const userText = rest.join(" ").trim();
const initialOutput = userText
? `Remembering: ${userText}`
: "Processing memory request...";
buffersRef.current.byId.set(cmdId, {
kind: "command",
id: cmdId,
input: msg,
output: initialOutput,
phase: "running",
});
buffersRef.current.order.push(cmdId);
refreshDerived();
setCommandRunning(true);
try {
// Import the remember prompt
const { REMEMBER_PROMPT } = await import(
"../agent/promptAssets.js"
);
// Build system-reminder content for memory request
const rememberMessage = userText
? `<system-reminder>\n${REMEMBER_PROMPT}\n</system-reminder>${userText}`
: `<system-reminder>\n${REMEMBER_PROMPT}\n\nThe user did not specify what to remember. Look at the recent conversation context to identify what they likely want you to remember, or ask them to clarify.\n</system-reminder>`;
// Mark command as finished before sending message
buffersRef.current.byId.set(cmdId, {
kind: "command",
id: cmdId,
input: msg,
output: userText
? `Remembering: ${userText}`
: "Processing memory request from conversation context...",
phase: "finished",
success: true,
});
refreshDerived();
// Process conversation with the remember prompt
await processConversation([
{
type: "message",
role: "user",
content: rememberMessage,
},
]);
} catch (error) {
const errorDetails = formatErrorDetails(error, agentId);
buffersRef.current.byId.set(cmdId, {
kind: "command",
id: cmdId,
input: msg,
output: `Failed: ${errorDetails}`,
phase: "finished",
success: false,
});
refreshDerived();
} finally {
setCommandRunning(false);
}
return { submitted: true };
}
// Special handling for /init command - initialize agent memory // Special handling for /init command - initialize agent memory
if (trimmed === "/init") { if (trimmed === "/init") {
const cmdId = uid("cmd"); const cmdId = uid("cmd");

View File

@@ -120,6 +120,13 @@ export const commands: Record<string, Command> = {
return "Starting skill creation..."; return "Starting skill creation...";
}, },
}, },
"/remember": {
desc: "Remember something from the conversation (optionally: /remember <what to remember>)",
handler: () => {
// Handled specially in App.tsx to trigger memory update
return "Processing memory request...";
},
},
}; };
/** /**