Skip to main content
Glama

search_long_term_memories

Retrieve relevant long-term memories from conversation history to maintain context and enable serendipitous recall.

Instructions

Search and activate relevant long-term memories based on current conversation context. Returns activated memories (whose triggers evaluated to true) and random memories for serendipity.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messagesYesRecent conversation messages
conversation_idYesCurrent conversation ID
participantsNoOptional participants information

Implementation Reference

  • The handler function that implements the core logic of the 'search_long_term_memories' tool. It processes input arguments to create context and invokes the LongTermMemoryManager to search and activate memories.
    handler: async (args) => {
      try {
        const context = {
          messages: args.messages,
          conversation_id: args.conversation_id,
          participants: args.participants || {}
        };
    
        const results = await memoryManager.searchAndActivateMemories(context);
    
        const formatMemory = (mem) => ({
          name: mem.name,
          prompt: mem.prompt,
          createdAt: mem.createdAt.toISOString(),
          updatedAt: mem.updatedAt?.toISOString()
        });
    
        return {
          activated: results.activated.map(formatMemory),
          random: results.random.map(formatMemory),
          totalMemories: memoryManager.getMemories().length,
          formattedText: memoryManager.formatActivatedMemories(results.activated, results.random)
        };
      } catch (error) {
        return {
          error: error.message
        };
      }
  • Zod input schema defining the expected parameters for the search_long_term_memories tool: recent messages, conversation ID, and optional participants.
    inputSchema: z.object({
      messages: z.array(z.object({
        role: z.enum(['user', 'assistant', 'system']),
        content: z.string()
      })).describe('Recent conversation messages'),
      conversation_id: z.string().describe('Current conversation ID'),
      participants: z.object({}).passthrough().optional().describe('Optional participants information')
    }),
  • The complete tool definition object for 'search_long_term_memories' within the createLongTermTools function, which registers the tool by including it in the returned array of MCP tools.
    {
      name: 'search_long_term_memories',
      description: 'Search and activate relevant long-term memories based on current conversation context. Returns activated memories (whose triggers evaluated to true) and random memories for serendipity.',
      inputSchema: z.object({
        messages: z.array(z.object({
          role: z.enum(['user', 'assistant', 'system']),
          content: z.string()
        })).describe('Recent conversation messages'),
        conversation_id: z.string().describe('Current conversation ID'),
        participants: z.object({}).passthrough().optional().describe('Optional participants information')
      }),
      handler: async (args) => {
        try {
          const context = {
            messages: args.messages,
            conversation_id: args.conversation_id,
            participants: args.participants || {}
          };
    
          const results = await memoryManager.searchAndActivateMemories(context);
    
          const formatMemory = (mem) => ({
            name: mem.name,
            prompt: mem.prompt,
            createdAt: mem.createdAt.toISOString(),
            updatedAt: mem.updatedAt?.toISOString()
          });
    
          return {
            activated: results.activated.map(formatMemory),
            random: results.random.map(formatMemory),
            totalMemories: memoryManager.getMemories().length,
            formattedText: memoryManager.formatActivatedMemories(results.activated, results.random)
          };
        } catch (error) {
          return {
            error: error.message
          };
        }
      }
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool 'Returns activated memories (whose triggers evaluated to true) and random memories for serendipity,' which provides some insight into the return behavior. However, it doesn't address important aspects like whether this is a read-only operation, potential side effects, performance characteristics, or error conditions. For a search tool with no annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with two clear sentences. The first sentence states the core functionality, and the second explains the return behavior. There's no unnecessary verbiage, and the information is front-loaded with the primary purpose stated first.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of memory search operations, no annotations, and no output schema, the description is incomplete. It doesn't explain what format the memories are returned in, how many memories are returned, whether there's pagination, or what constitutes 'relevant' versus 'random' memories. For a tool with 3 parameters (including a nested object) and no structured output documentation, the description should provide more operational context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description provides no information about parameters beyond what's already in the schema. Since schema description coverage is 100% (all parameters have descriptions), the baseline score is 3. The description doesn't add any additional context about how parameters should be used or their significance in the search process.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Search and activate relevant long-term memories based on current conversation context.' It specifies the verb ('search and activate'), resource ('long-term memories'), and context ('current conversation context'). However, it doesn't explicitly differentiate from sibling tools like 'search_memories' or 'search_short_term_memories', which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With multiple sibling search tools (search_memories, search_short_term_memories), there's no indication of when this specific long-term memory search is appropriate versus other search options. The description only states what the tool does, not when to choose it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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