Support-task replay
An agent handles recurring support requests and reuses successful prior interaction sequences.
AI Agents · Const
Episodic memory captures past events and actions so an agent can remember how tasks were accomplished. It is commonly reused as few-shot examples that guide future task execution.
Episodic memory records past events or actions, especially the experiences behind successful task completion. Agents commonly reuse these records as few-shot examples, allowing future behavior to reflect how similar tasks were handled rather than only retaining isolated facts.
import { ChatOpenAI } from "@langchain/openai";
import { HumanMessage } from "@langchain/core/messages";
const model = new ChatOpenAI({ model: "gpt-4o-mini" });
const examples = [
{ input: "Reset my password", approach: "Verify identity, then send a reset link." },
];
const prompt = `Use this past experience as a guide:\n${JSON.stringify(examples)}\n\nUser: Reset my password`;
const response = await model.invoke([new HumanMessage(prompt)]);
console.log(response.content);A previous interaction is stored as a few-shot example and inserted into a later prompt so the agent can reuse the demonstrated approach.
An agent handles recurring support requests and reuses successful prior interaction sequences.
An agent selects previous task demonstrations to guide a new but similar workflow.
An application preserves experiences across conversations for later reuse.
Episodic memory is memory of previous events or actions. In an agent, it is useful for remembering how to accomplish a task, often by reusing past sequences as few-shot examples.
Follow-up: How does it differ from semantic memory? Semantic memory stores facts, while episodic memory stores experiences and task trajectories.
A common implementation stores prior successful interaction sequences and includes selected examples in a later prompt. This gives the model demonstrations of an effective approach to imitate.
Follow-up: What should retrieval optimize for? It should select examples relevant to the current task rather than indiscriminately adding old interactions.
The distinction is based on content: semantic memory captures facts, whereas episodic memory captures experiences. Episodic records therefore help an agent reproduce a method, not just recall information.
Follow-up: Can one interaction contain both types? Yes; its factual outcome can become semantic memory while the sequence and method remain episodic memory.
Semantic memoryProcedural memoryLong-term memoryFew-shot example prompting