Skip to main content
Glama

prioritize_memory

Prioritize AI development memories by importance to focus on critical decisions, code changes, blockers, and next steps for current tasks.

Instructions

중요한 거|우선순위|prioritize|important|what matters|priority - Prioritize memories by importance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
currentTaskYesCurrent task description
criticalDecisionsNoList of critical decisions made
codeChangesNoImportant code changes
blockersNoCurrent blockers or issues
nextStepsNoPlanned next steps

Implementation Reference

  • The core handler function that executes the prioritize_memory tool. It calculates priority scores for memories based on content analysis, current task relevance, critical decisions, code changes, and blockers, then updates priorities and returns top 20 prioritized memories.
    export async function prioritizeMemory(args: { currentTask: string; criticalDecisions?: string[]; codeChanges?: string[]; blockers?: string[]; nextSteps?: string[] }): Promise<ToolResult> { const { currentTask, criticalDecisions = [], codeChanges = [], blockers = [], nextSteps = [] } = args; try { const mm = MemoryManager.getInstance(); const allMemories = mm.list(); const prioritizedMemories: Array<{ memory: MemoryItem; priority: number; reason: string }> = []; for (const memory of allMemories) { let priority = 0; let reason = ''; // Analyze importance based on content if (memory.value.includes('error') || memory.value.includes('Error')) { priority = 0.9; reason = 'error info'; } else if (memory.value.includes('decision') || memory.value.includes('Decision')) { priority = 0.8; reason = 'decision'; } else if (memory.value.includes('code') || memory.value.includes('function')) { priority = 0.7; reason = 'code-related'; } else if (memory.category === 'context') { priority = 0.6; reason = 'context'; } else if (memory.category === 'project') { priority = 0.7; reason = 'project'; } else { priority = 0.5; reason = 'general'; } // Boost priority for memories related to current task if (memory.value.toLowerCase().includes(currentTask.toLowerCase())) { priority += 0.2; reason += ' +task'; } // Boost priority for critical decisions for (const decision of criticalDecisions) { if (memory.value.toLowerCase().includes(decision.toLowerCase())) { priority += 0.15; reason += ' +critical'; break; } } // Boost priority for code changes for (const change of codeChanges) { if (memory.value.toLowerCase().includes(change.toLowerCase())) { priority += 0.1; reason += ' +change'; break; } } // Boost priority for blockers for (const blocker of blockers) { if (memory.value.toLowerCase().includes(blocker.toLowerCase())) { priority += 0.25; reason += ' +blocker'; break; } } // Cap priority at 1.0 priority = Math.min(1.0, priority); if (priority >= 0.6) { prioritizedMemories.push({ memory, priority, reason }); // Update priority in database mm.setPriority(memory.key, Math.floor(priority * 100)); } } const sortedMemories = prioritizedMemories .sort((a, b) => b.priority - a.priority) .slice(0, 20); const resultList = sortedMemories.map(pm => `• [${(pm.priority * 100).toFixed(0)}%] ${pm.memory.key} (${pm.reason}): ${pm.memory.value.substring(0, 60)}${pm.memory.value.length > 60 ? '...' : ''}` ).join('\n'); return { content: [{ type: 'text', text: `✓ Prioritized ${sortedMemories.length} memories for "${currentTask}":\n${resultList || 'None'}` }] }; } catch (error) { return { content: [{ type: 'text', text: `✗ Error: ${error instanceof Error ? error.message : 'Unknown error'}` }] }; } }
  • The ToolDefinition object defining the input schema, description, and annotations for the prioritize_memory tool.
    export const prioritizeMemoryDefinition: ToolDefinition = { name: 'prioritize_memory', description: '중요한 거|우선순위|prioritize|important|what matters|priority - Prioritize memories by importance', inputSchema: { type: 'object', properties: { currentTask: { type: 'string', description: 'Current task description' }, criticalDecisions: { type: 'array', items: { type: 'string' }, description: 'List of critical decisions made' }, codeChanges: { type: 'array', items: { type: 'string' }, description: 'Important code changes' }, blockers: { type: 'array', items: { type: 'string' }, description: 'Current blockers or issues' }, nextSteps: { type: 'array', items: { type: 'string' }, description: 'Planned next steps' } }, required: ['currentTask'] }, annotations: { title: 'Prioritize Memory', audience: ['user', 'assistant'], readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false } };
  • src/index.ts:166-166 (registration)
    Registration of the prioritizeMemory handler in the toolHandlers registry for dynamic dispatch.
    'prioritize_memory': prioritizeMemory,
  • src/index.ts:99-99 (registration)
    Inclusion of the prioritizeMemoryDefinition in the tools array used for listing available tools.
    prioritizeMemoryDefinition,
  • src/index.ts:47-47 (registration)
    Import statement bringing in the tool definition and handler from the implementation file.
    import { prioritizeMemoryDefinition, prioritizeMemory } from './tools/memory/prioritizeMemory.js';

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/su-record/hi-ai'

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