{
  "id": 222329,
  "title": "Agent Memory in TypeScript: Short-Term, Long-Term, and What to Throw Away",
  "url": "https://urgent.news/2026/08/06/agent-memory-in-typescript-short-term-long-term-and-what-to-throw-away",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-08-06T14:20:42.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/gabrielanhaia/agent-memory-in-typescript-short-term-long-term-and-what-to-throw-away-303b"
  },
  "original_language": "en",
  "account": "The implementation of \"agent memory\" in TypeScript is represented by a single array of messages that expands until a certain point, at which point something forces it to truncate. This one array handles three tasks with varying durations of relevance, access patterns, and failure points, which is why the truncation always appears to be random. In order to resolve this issue, it is recommended to separate the three functions, each with its own distinct lifetime and access pattern.\n\nThere are three distinct types of memory: working memory, long-term memory, and episodic memory. Working memory contains the message window sent in the current turn and is only available to the model during that specific run. Long-term memory retains durable information about the user or the domain, which is not sent to the model all at once but retrieved selectively. Episodic memory records previous runs and is mainly used for debugging, analytics, and evaluations, rarely sent to the model.\n\nSeparating these three types of memory into their respective interfaces – WorkingMemory, LongTermMemory, and EpisodicMemory – clarifies their distinct purposes and eliminates the common mistake of conflating them. The WorkingMemory interface includes functions to manage the message window, append new messages, and compact the memory based on a given budget. The LongTermMemory interface allows for recalling, remembering, and forgetting facts, while the EpisodicMemory interface provides methods for recording and finding specific runs.\n\nBy implementing separate interfaces for each type of memory, it becomes clear that a single Memory interface with get/set methods is the root cause of the confusion. The working memory, with its budget, handles the current message window, while long-term memory deals with durable user or domain facts and episodic memory stores records of past runs for various purposes.",
  "summary": "Book: AI That Plans The series: AI in TypeScript — 5 books, from your first LLM call to agents in production — all five here My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub \"Agent memory\" gets implemented as one array of messages that grows until something truncates it. That single array is doing three jobs that…",
  "key_points": [
    "Three types of memory: working, long-term, and episodic",
    "Separating memory types clarifies purposes, resolves truncation confusion"
  ],
  "editors_take": "Separating agent memory into distinct working, long-term, and episodic components clarifies their purposes, eliminates conflation, and resolves the issue of seemingly random truncation of a unified memory array.",
  "illustration": "https://urgent.news/ill/222329.png",
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}