Skip to main content
Glama

history

Retrieve recent conversation history for a session in chronological order to maintain context and continuity in AI agent interactions.

Instructions

Get recent conversation history for a session in chronological order.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession identifier
limitNoMax entries (default 20)

Implementation Reference

  • The 'history' method is the core handler that retrieves recent conversation history for a session. It delegates to the 'recall' method with the sessionId and limit parameters.
    async history(sessionId: string, limit: number = 20): Promise<MemoryEntry[]> {
      return this.recall(sessionId, undefined, limit, {});
    }
  • src/index.ts:68-78 (registration)
    Tool registration defining the 'history' tool with its name, description, and input schema (sessionId required, limit optional with default 20).
      name: 'history',
      description: 'Get recent conversation history for a session in chronological order.',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId:  { type: 'string', description: 'Session identifier' },
          limit:      { type: 'number', description: 'Max entries (default 20)', default: 20 },
        },
        required: ['sessionId'],
      },
    },
  • The case handler that invokes memory.history() when the 'history' tool is called, passing sessionId and limit arguments, returning JSON-formatted entries.
    case 'history': {
      const entries = await memory.history(
        args.sessionId as string,
        (args.limit as number) || 20
      );
      return { content: [{ type: 'text', text: JSON.stringify(entries, null, 2) }] };
    }
  • MemoryEntry interface defines the output schema for history results: id, sessionId, content, role, timestamp, optional metadata and similarity.
    export interface MemoryEntry {
      id: string;
      sessionId: string;
      content: string;
      role: 'user' | 'assistant' | 'system';
      timestamp: Date;
      metadata?: Record<string, unknown>;
      similarity?: number;
    }

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/Cartisien/engram-mcp'

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