From 23b335fee7cd9bb3376347fbef0023e17935d8fc Mon Sep 17 00:00:00 2001 From: Charles Packer Date: Thu, 11 Dec 2025 15:13:48 -0800 Subject: [PATCH] feat: add /remember command for quick memory updates (#179) Co-authored-by: Letta --- src/agent/promptAssets.ts | 2 + src/agent/prompts/remember.md | 29 ++++++++++++++ src/cli/App.tsx | 74 +++++++++++++++++++++++++++++++++++ src/cli/commands/registry.ts | 7 ++++ 4 files changed, 112 insertions(+) create mode 100644 src/agent/prompts/remember.md diff --git a/src/agent/promptAssets.ts b/src/agent/promptAssets.ts index 15384e2..18ce2a4 100644 --- a/src/agent/promptAssets.ts +++ b/src/agent/promptAssets.ts @@ -14,6 +14,7 @@ import personaEmptyPrompt from "./prompts/persona_empty.mdx"; import personaKawaiiPrompt from "./prompts/persona_kawaii.mdx"; import planModeReminder from "./prompts/plan_mode_reminder.txt"; import projectPrompt from "./prompts/project.mdx"; +import rememberPrompt from "./prompts/remember.md"; import skillCreatorModePrompt from "./prompts/skill_creator_mode.md"; import skillUnloadReminder from "./prompts/skill_unload_reminder.txt"; import skillsPrompt from "./prompts/skills.mdx"; @@ -25,6 +26,7 @@ export const PLAN_MODE_REMINDER = planModeReminder; export const SKILL_UNLOAD_REMINDER = skillUnloadReminder; export const INITIALIZE_PROMPT = initializePrompt; export const SKILL_CREATOR_PROMPT = skillCreatorModePrompt; +export const REMEMBER_PROMPT = rememberPrompt; export const MEMORY_PROMPTS: Record = { "persona.mdx": personaPrompt, diff --git a/src/agent/prompts/remember.md b/src/agent/prompts/remember.md new file mode 100644 index 0000000..ba20b02 --- /dev/null +++ b/src/agent/prompts/remember.md @@ -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. diff --git a/src/cli/App.tsx b/src/cli/App.tsx index 90f7329..b09ae3a 100644 --- a/src/cli/App.tsx +++ b/src/cli/App.tsx @@ -1673,6 +1673,80 @@ export default function App({ 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 + ? `\n${REMEMBER_PROMPT}\n${userText}` + : `\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`; + + // 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 if (trimmed === "/init") { const cmdId = uid("cmd"); diff --git a/src/cli/commands/registry.ts b/src/cli/commands/registry.ts index f389c3d..6b4694d 100644 --- a/src/cli/commands/registry.ts +++ b/src/cli/commands/registry.ts @@ -120,6 +120,13 @@ export const commands: Record = { return "Starting skill creation..."; }, }, + "/remember": { + desc: "Remember something from the conversation (optionally: /remember )", + handler: () => { + // Handled specially in App.tsx to trigger memory update + return "Processing memory request..."; + }, + }, }; /**