get_frequent_conversation
Retrieve the most frequently mentioned conversation ID from stored memories to identify recurring discussion topics.
Instructions
Get the most frequently mentioned conversation ID in memories.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/short-term-tools.js:199-219 (handler)MCP tool handler for 'get_frequent_conversation': defines the tool with empty input schema and handler that calls ShortTermMemoryManager.getMostFrequentConversation() to retrieve and return the most frequent conversation ID.{ name: 'get_frequent_conversation', description: 'Get the most frequently mentioned conversation ID in memories.', inputSchema: z.object({}), handler: async (args) => { try { const mostFrequent = memoryManager.getMostFrequentConversation(); return { conversation_id: mostFrequent, message: mostFrequent ? `Most frequent conversation: ${mostFrequent}` : 'No memories found' }; } catch (error) { return { error: error.message }; } } }
- src/memory/short-term.js:703-721 (helper)Core implementation in ShortTermMemoryManager: counts occurrences of each conversation_id across all memories and returns the ID with the highest count (or null if no memories).getMostFrequentConversation() { if (this.memories.length === 0) return null; const counts = {}; for (const mem of this.memories) { counts[mem.conversation_id] = (counts[mem.conversation_id] || 0) + 1; } let maxCount = 0; let mostFrequent = null; for (const [id, count] of Object.entries(counts)) { if (count > maxCount) { maxCount = count; mostFrequent = id; } } return mostFrequent; }
- src/index.js:152-154 (registration)Registers all short-term tools (including 'get_frequent_conversation') from createShortTermTools into the global toolRegistry with 'short-term' scope for the default conversation.// 注册所有短期记忆工具 const shortTermTools = createShortTermTools(defaultShortTermManager, defaultStorageManager); shortTermTools.forEach(tool => registerTool(tool, 'short-term'));