Skip to main content
Glama

update_long_term_memory

Modify existing long-term memories by updating trigger conditions, content, or context to maintain accurate and relevant stored information over time.

Instructions

Update an existing long-term memory. You can update the trigger condition, prompt content, or add update context.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
triggerNo
promptNo
updatedContextNo
recentMessagesNo

Implementation Reference

  • The handler function that executes the core logic of the update_long_term_memory tool. It processes optional updates to trigger, prompt, and context, calls the underlying memory manager to perform the update, persists changes to storage, and returns a structured success or error response.
    handler: async (args) => { try { // Auto-generate context if messages provided let updatedContext = args.updatedContext; if (!updatedContext && args.recentMessages) { updatedContext = createContextSnapshot(args.recentMessages, 4); } const updates = { trigger: args.trigger, prompt: args.prompt, updatedContext }; // Remove undefined values Object.keys(updates).forEach(key => { if (updates[key] === undefined) delete updates[key]; }); const result = await memoryManager.updateMemory(args.name, updates); if (result.success) { await storageManager.saveLongTermMemories(memoryManager.getMemories()); return { success: true, message: `Memory "${args.name}" updated successfully` }; } else { return { success: false, error: result.error }; } } catch (error) { return { success: false, error: error.message }; } }
  • Zod input schema defining the parameters for updating a long-term memory, including optional fields for trigger, prompt, context, and recent messages.
    inputSchema: z.object({ name: z.string().describe('Name of the memory to update'), trigger: z.string().optional().describe('New trigger condition (JavaScript code)'), prompt: z.string().optional().describe('New memory content'), conversation_id: z.string().optional().describe('Conversation ID that owns this memory'), updatedContext: z.string().optional().describe('Context about this update'), recentMessages: z.array(z.object({ role: z.enum(['user', 'assistant', 'system']), content: z.string() })).optional().describe('Optional recent messages to auto-generate updatedContext') }),
  • src/index.js:157-158 (registration)
    Static registration of long-term tools (including update_long_term_memory) into the tool registry using default managers for list_tools requests.
    const longTermTools = createLongTermTools(defaultLongTermManager, defaultStorageManager); longTermTools.forEach(tool => registerTool(tool, 'long-term'));
  • src/index.js:291-295 (registration)
    Dynamic recreation of conversation-specific long-term tools during tool execution and invocation of the specific tool handler by name.
    manager = await getLongTermManager(conversationId); storage = getStorageManager(conversationId); const tools = createLongTermTools(manager, storage); const tool = tools.find(t => t.name === toolName); result = await withTimeout(tool.handler(validatedArgs), timeout, `Tool ${toolName} timeout`);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/win10ogod/memory-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server