Hypothetical scenario. Northwind can recover a task, but an unsupported assumption from an earlier conversation reappears as remembered fact. Maya corrects it. Dev locates the saved note, and Priya asks which future paths might still retrieve it.
Maya: “I corrected that assumption already. Why is it back?”
Dev: “The note was saved without a clear source or correction path.”
Priya: “Distinguish working notes from reusable knowledge, then follow the correction through retrieval.”
You will separate scratchpads, episodic records and semantic memory, tracing provenance, access, promotion and forgetting. Persistence preserves a representation; its eligibility for another task needs a separate decision.
Which part of yesterday’s run deserves to become memory?
A short-term scratchpad holds temporary run-local material. An episodic record describes a particular past interaction or attempt, including its outcome. Semantic memory stores reusable facts or abstractions rather than the full event sequence. These labels describe different eligibility and correction decisions; they do not imply that a vector store supplies an intrinsically reliable memory. Long-running session state still needs durable identity and recovery even when no memory is reused across sessions.
Hypothetical scenario. A run creates six notes, but only two refer to verified, reusable source facts. If those two become semantic records, four remain local or expire: 6 − 2 = 4. Retaining all six because they are easy to embed would also preserve speculation. Link each reusable record to its permitted source and version. When the source is corrected, invalidate or supersede the dependent record rather than merely adding a contradictory second memory.
Yesterday's guess becomes today's confident answer
Northwind's assistant once inferred that a supplier preferred email. The inference entered a reusable memory record without its source or uncertainty. A later task treats it as an explicit supplier instruction. Priya now sees a confident recommendation built on a fact nobody actually established. The problem began when a tentative observation changed status during storage.
Memory can help avoid repeatedly collecting the same information, but it can also preserve an error beyond the conversation that exposed its uncertainty. A useful design distinguishes an observed event, a user preference, an inferred hypothesis and an approved operating instruction. Each may need a different writer, retention policy and retrieval rule.
Give memory an evidence and correction lifecycle
Hypothetical scenario. A run writes a memory claiming a policy applies to contractor accounts. Record whether this came from a source, user statement or model inference, with source revision and scope. A later correction must be able to find dependent memories and summaries.
| Artifact | Concrete evidence | Decision boundary |
|---|---|---|
| Memory claim | identity, provenance type, scope | Interpretation |
| Evidence | source revision or event reference | Support |
| Lifecycle | active, corrected, retired, retained reason | Correction / forgetting |
Scratchpad state, episodic event records and reusable semantic claims have different lifetimes. Saving every conversation does not make each claim trustworthy. Apply current permission when retrieving memory and distinguish expiry from authoritative correction. A corrected source should supersede unsupported claims rather than merely adding a conflicting newer note that a retriever may miss. Forgetting also includes derived summaries and caches under the declared retention policy.
Why saving every message is not enough
A complete transcript preserves conversational detail but leaves later readers to reconstruct which statements were accepted, superseded or speculative. A short summary reduces text while potentially removing the evidence that qualified a claim. Neither format alone defines the application's record model.
Start with the future decision the record will support. Remembering a preferred display language is different from remembering an authorization decision. A display preference may be safely offered as a default that the person can change. Authority to publish a document should come from the current policy and actor context rather than from an old conversation saying that someone was once an administrator.
Thread state and cross-task records have different jobs
LangChain's memory overview distinguishes thread-scoped memory from information maintained across conversations. A checkpointer can preserve the execution state of one thread; a store can hold application-defined records used by later tasks. These are persistence scopes, not levels of factual reliability.
For Northwind, the current investigation's pending observations belong with its workflow state. A supplier contact preference can belong in a scoped record with a source and update history. A completed publication outcome belongs in an action ledger whose identity supports later reconciliation. Combining everything in one vector collection makes these differences harder to enforce.
A memory record can include its subject, type, source, observation time, applicable interval, revision and eligible readers. Some fields are useful for ranking; others are required for permission checks or correction. Keep those uses distinct. A highly similar memory that the current actor cannot access must not enter the model context.
Design the record's complete lifecycle
Follow the decision boundaries
The lifecycle starts with a candidate observation, not an automatic durable fact. Validation determines whether and how it should be stored. Later retrieval checks eligibility and relevance. A correction can supersede the record, while deletion or expiry can remove its future applicability. The cycle gives mistakes a supported exit rather than allowing them to accumulate indefinitely.
Work through a bounded memory selection
Hypothetical scenario. A task has a selected memory allowance of 2,000 tokens. It finds eight candidate records, each represented by a chosen 300-token excerpt. The candidate payload is 8 × 300 = 2,400 tokens, which exceeds the allowance by 2,400 − 2,000 = 400 tokens. These are example token counts, not a claim about a particular tokenizer.
Suppose two candidates are obsolete and one belongs to another tenant, with no overlap between those categories. Eligibility removes 2 + 1 = 3 records, leaving 8 − 3 = 5. Their payload is 5 × 300 = 1,500 tokens. The remaining allowance is 2,000 − 1,500 = 500 tokens. That margin does not justify reintroducing unauthorized or obsolete records simply because they fit.
Now assume a provenance note uses 40 tokens per retained record. The notes add 5 × 40 = 200 tokens, bringing the memory package to 1,500 + 200 = 1,700 tokens. The final margin is 300 tokens. Count the representation actually sent to the model, including evidence labels and separators, rather than counting only the excerpt body.
Correct a claim without losing its history
Suppose record M1 says the supplier prefers email, based on an inferred reading of an old conversation. An authorized supplier contact later states a different preference. Northwind can create M2 with the explicit source and mark M1 as superseded. Retrieval should select the currently applicable record and expose any unresolved conflict needed for the task.
Deleting the text of M1 from one store is not the whole correction if a cached summary, embedding index or copied task context can still reproduce it. Identify derived views and their refresh behavior. A correction policy should explain when each view stops serving the older assertion. An evaluation case can query through those views rather than checking only the authoritative record table.
Preserve enough lineage to explain why M2 replaced M1 without unnecessarily retaining sensitive text forever. Audit requirements, privacy requirements and operational usefulness can pull in different directions. The storage design needs a declared retention policy; a large context window is not such a policy.
In the wild: memory is represented by scope
The official LangChain memory documentation describes thread-level state and longer-lived memory used across interactions. This is a concrete implementation vocabulary for separating a current conversation from reusable application records. It does not assert that all remembered content is accurate or that retrieval automatically respects Northwind's access policy.
Use that distinction to inspect your own memory boundary. Ask where a record is written, what identifies its owner, how it can be changed and how the next task decides that it is eligible. The supplier-preference story remains hypothetical; it illustrates a failure mode rather than reporting a customer incident.
Choose what deserves persistence
Not every model observation deserves a cross-task record. Transient speculation can stay in a bounded investigation. A stable preference can be recorded with a clear source. A security-sensitive assertion can require an authoritative system lookup on every relevant action. Select the write policy before optimizing memory retrieval.
A useful memory evaluator includes at least three kinds of task: one helped by an established record, one harmed by a stale record and one that should ignore a record because the current actor is ineligible. A system that recalls many statements can perform poorly on the latter two. Evaluate the resulting decision as well as whether the expected record appeared in the candidate list.
Records can also be relevant only during an interval. A temporary delivery instruction may expire after one order. Represent that scope directly instead of hoping a model infers it from an old message. Retrieval should pass the current task identity and time context through the eligibility rule before ranking candidates.
A belief state is not an evidence archive
Decision theory uses beliefs to represent uncertainty about a state that is not completely observed. That is a useful conceptual comparison, but an application memory table does not become a calibrated probability model simply because it stores confidence numbers. A numeric confidence needs a defined interpretation and evidence about its calibration.
For a business assistant, a source-linked assertion with an explicit unknown can be more inspectable than a confident decimal. Preserve the distinction between evidence, an inference drawn from it and a policy that permits an action. Those three records answer different questions even when they concern the same supplier.
Three ways memory creates accidental authority
Repeated retrieval validates a claim. The same unsupported record can be retrieved many times without acquiring new evidence.
A user-specific namespace establishes every access rule. Namespaces help organize records, but the application still has to enforce which identities and operations may use them.
A summary safely replaces the source. A summary can be useful context, but a consequential decision may require the original qualified statement and its current revision.
Test forgetting through the route the next task uses
A deletion test should start from a record that the assistant could previously retrieve. Exercise the authoritative store, the derived index and any context-building cache involved in the actual request path. A successful deletion call to one component does not show that a later answer can no longer receive the old content from another component.
For Northwind, select a supplier preference with an explicit source and create a correction. Ask the same task through the normal interface before and after the selected update boundary. Inspect which record revision reaches the model, not only the final answer. A model might produce the corrected answer by chance even while the old record remains eligible.
Also test the negative case: another tenant should not gain access merely because a record was moved, summarized or embedded again. Eligibility should follow the subject and applicable policy across those transformations. A summary that drops the owner identity can turn a useful optimization into a disclosure path.
Finally, define what forgetting means for execution history. Removing a reusable preference does not necessarily remove a required audit record of an authorized action. Keep those purposes separate and apply the appropriate retention policy to each. The design should state its guarantees precisely instead of promising that one delete button removes every possible copy everywhere.
Where memory design remains application-specific
Record types, retention intervals and correction policies depend on the task and data obligations. The token calculation assumes fixed excerpt sizes and disjoint exclusion categories. Neither a store nor a checkpointer supplies truth, calibrated beliefs or current action authority. This chapter's lifecycle is a proposed application design; verify storage deletion, cache invalidation and access behavior in the implementation used for release.
Test the memory claim boundary
A remembered model guess is retrieved as established policy. What failed?
Reveal the design reasoning
Provenance and acceptance failed. Label or exclude inference, resolve current source evidence and invalidate dependent summaries. Retrieval similarity cannot promote a guess into authority.
Decision: Publish reusable memory with support, scope and a correction owner.
Inspect the memory decision
A helpful old note says the actor can publish policies. May the assistant use it as authority?
Use the current authoritative permission source. The note can explain historical context but should not replace present access validation. Remembered authority can outlive a role change, which is precisely the lifecycle error the design must prevent.
Why are there only five eligible records in the token example?
Two obsolete and one cross-tenant candidates are removed from the eight under the stated disjoint categories. Eligibility precedes ranking and packaging. With provenance, the five records occupy 1,700 tokens; the remaining 300 tokens do not relax their scope constraints.
A correction updates the authoritative record, but a cached summary repeats the old claim. Is the correction complete?
Not for readers of that summary. Trace the derived view, its revision identity and invalidation policy. Define when old assertions stop being eligible across every path that can influence the next decision, then test through those paths.
Northwind decision log
- Store an assertion with its type, source, scope and applicable revision.
- Filter eligibility before ranking or packaging remembered records.
- Propagate correction and expiry through the paths that build the next context.
Go deeper: supporting mechanisms
- Video lecture: Long-term Memory: LangMem SDK Conceptual Guide, LangChain. Contrast uncertain state estimates with evidence-backed memory records.
- Book chapter: Algorithms for Decision Making, chapter 19: Beliefs, Mykel J. Kochenderfer, Tim A. Wheeler and Kyle H. Wray. Contrast uncertain state estimates with evidence-backed memory records.
- Book chapter: Algorithms for Decision Making, chapter 20: Exact Belief State Planning, Mykel J. Kochenderfer, Tim A. Wheeler and Kyle H. Wray. Contrast uncertain state estimates with evidence-backed memory records.
- Primary document: Agent memory provenance correction reference. Inspect the distinction between thread state and cross-conversation memory.
Related: Agentic systems · Retries and tool outcomes.
Check the mechanism in this lesson
Why should four unverified scratchpad notes not automatically become four semantic memories?
Compare the explanation
They were temporary material, not established reusable facts. Promotion needs provenance, permission and a correction policy. Embedding them preserves their text without validating the underlying claims.
Carry the decision forward
Northwind can choose eligible memory without treating persistence as truth. Page 24 bounds the attempts, time and cost that a resumed or self-correcting run may consume.