Give your agent a useful memory, not a junk drawer
Keep the context that improves the next task. Separate durable preferences from current state, save decisions with evidence, and make old notes easy to correct or retire.
Jump to the exerciseWhat you’ll be able to do
- Decide what deserves to survive beyond the current conversation.
- Write memory notes that preserve scope, evidence, and freshness.
- Test whether an agent retrieves the right note and updates it correctly.
1. Check what the product means by memory
Memory can mean several different things: the conversation currently visible to the model, saved notes reused across conversations, files in a project, or information retrieved from a connected knowledge base. These mechanisms have different limits and controls. Before relying on any of them, find out what your agent stores, when it reads that information, and how you can inspect or remove it.
LangChain's memory documentation distinguishes information scoped to one conversation from information reused across conversations. That distinction is useful even if you never use its software. A deadline for today's task belongs in current task state. A preference for dates in day-month-year format might belong in persistent preferences. Keeping those separate prevents an expired deadline from appearing to govern unrelated work next month.
Ask a concrete memory question
Show which saved instructions you will use for this project. Identify where each is stored and whether you can edit it. If you cannot inspect saved memory, say so and use the attached project note for this task.
2. Save facts that change future decisions
Useful memory reduces repeated explanation. It can preserve a writing preference, a project convention, a settled decision, or a recovery procedure that was actually verified. A transcript contains much more: abandoned ideas, temporary errors, jokes, guesses, and obsolete instructions. Saving the whole conversation without curation makes the next task responsible for sorting all of that again.
Use a simple test: will this fact change a likely future action, and can I say where it applies? ‘Use the existing invoice template for customer invoices’ can guide repeat work. ‘We discussed invoices on Tuesday’ rarely can. Store a pointer to a large source document instead of copying it into every note. Anthropic's context-engineering guidance treats context as a finite resource and discusses retrieving relevant information when needed. The practical aim is a compact starting point with a path to deeper evidence.
Choose one future decision
Name the action the note should influence, such as selecting a template or preserving a design choice.
State the scope
Specify the project, team, task type, or person the note applies to.
Keep the evidence nearby
Link to the source, decision record, or verified result that makes the note trustworthy.
Sort the memory drawer
Decide which sample notes belong in durable memory, which belong only in the current task, and which should be discarded or rewritten.
Give each piece of context a home. The useful question is how long it should remain authoritative.
0 of 4 correctly placed
4 pieces of context still need a home.
3. Give each note a small structure
Write a memory note with five fields: fact or preference, scope, source, date checked, and refresh condition. The refresh condition names the event that makes the note questionable. A team convention might need review when ownership changes. A tested command might need review after a dependency update. A product price needs current verification whenever it affects a purchase decision.
Separate an observed fact from your interpretation. ‘The export contained 148 rows’ is an observation about one run. ‘Exports always include every record’ is a much broader claim that the observation does not establish. A durable note should preserve that limit. When the agent proposes a memory update, inspect the actual wording. Small changes such as replacing ‘in this project’ with ‘always’ can turn a helpful preference into an unwanted rule.
A compact memory card
Preference: Use the short customer-update template. Scope: The monthly Atlas project update. Source: Approved example in the project folder. Checked: 2 October 2026. Refresh when: The audience or update format changes. Do not apply this preference to incident reports.
4. Resolve contradictions explicitly
As work changes, memory will contain conflicts. One note might say to send a weekly digest; a later decision might replace it with a monthly report. Ask the agent to identify the conflict, inspect the authoritative source, and propose a replacement note. Do not simply add a third note describing the contradiction. Repeated additions leave the next agent to make the same decision again.
Give current instructions their proper context. If you ask for an unusual format today, say whether it is a one-time exception or a new default. If the agent misapplies an old preference, correct the stored scope instead of repeatedly compensating in every prompt. Keep a small change record for consequential team decisions. It should show what was superseded and why, so a future reader can distinguish a deliberate change from an accidental deletion.
5. Test retrieval with a fresh task
A note being saved does not prove the agent will use it. Start a fresh task that should benefit from the note and ask the agent to identify the relevant preference before acting. Check both inclusion and exclusion: it should use the Atlas update template for an Atlas monthly update, and leave that template aside for an unrelated incident report.
If the right note is not retrieved, inspect its title, scope, storage location, and the product's retrieval behavior. A concise note titled ‘Atlas monthly customer updates’ is easier to target than a large file called ‘Things to remember.’ If too many unrelated notes appear, narrow the memory set available to the task. Keep the test small enough that you can compare the actual output with the approved example and identify which instruction caused a mistake.
A two-task check
Task A: Draft the monthly Atlas update from supplied facts. Expected: the approved short template. Task B: Draft an incident report from supplied facts. Expected: an incident structure with timeline and impact, without importing the Atlas update template.
6. Retire notes as deliberately as you save them
Review memory when a project ends, a decision changes, or a note causes a wrong action. Archive finished task state and remove duplicates. Keep credentials and private account tokens in their intended secret store, not in memory notes. Record only the personal details that are necessary for the work and that you actually want reused.
Use the memory sorter to practice choosing between retain, task only, and discard. Some notes need rewriting before they fit any category. ‘The customer is difficult’ is a judgment with little operational value. ‘For this customer, attach the source spreadsheet and state assumptions explicitly, as requested in the kickoff’ preserves an actionable preference with a source. Good memory should make the next task easier to start and easier to audit, while remaining small enough for you to understand what the agent thinks it knows.
When things go wrong
Start with the failure you can observe.
The agent repeats an outdated decision.
Find the stored note, verify the current decision, and replace or supersede the old note. Include the date and the condition that changed.
A personal preference appears in every project.
Narrow the note's scope and test it on one relevant task and one unrelated task. Move project-specific notes out of global preferences where possible.
The agent remembers the story but misses the instruction.
Rewrite the note around the future action, expected result, and source. Keep background detail in a linked document.
Put it into practice
0 / 5Use this checklist on your next real task.
Your checklist is saved in this browser. Exercise inputs are not saved.
Sources & further reading
Primary references for the ideas in this chapter. Product behavior can change; check the documentation for the version you use.
- LangChain: Memory overview
Provides the distinction between conversation-scoped and cross-conversation memory. The memory-card format in this guide is an editorial recommendation.
- Anthropic: Effective context engineering
Supports curating relevant context, retrieving detail when needed, and using structured notes for longer tasks.
Edited October 7, 2026 · Examples are illustrative unless attributed.