What is the difference between short-term and long-term memory in agents?
Short-term (working) memory is the context window: the running transcript of thoughts, tool calls, and observations for the current task. It's fast and coherent but bounded, so long tasks force truncation or summarization, and older details fall out. Long-term memory persists across sessions and beyond the window, typically stored externally, in a vector database (for semantic recall), a key-value store, or a structured DB, and retrieved on demand. Patterns include episodic memory (past interactions), semantic memory (facts/knowledge), and procedural memory (learned skills). The engineering challenge is what to write, when to retrieve, and how to keep it relevant without polluting context. Poor memory management causes either amnesia (forgetting key facts) or context bloat (stuffing in irrelevant history that raises cost and distracts the model).