Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

Agent Memory

Free · sign in to start and track progress

1 · How agents remember

  • 1Memory types for agents
  • 2The context window as working memory

    Exercise answers

    • Answer: Measure fact drift across repeated compaction
    • Answer: Re-inject matter state after compaction in Claude Code
  • 3Files, skills and memory tools
  • 4Memory frameworks and benchmarks

2 · Memory in production

  • 5Scoping, retention and erasure
  • 6Write, update and forget
  • 7Shared state and memory poisoning
  • 8Evaluating memory
CapstoneA memory layer for a 12-week caseReference implementation

Module 1 · How agents remember · Lesson 2

The context window as working memory

How compaction, context editing and Claude Code's compaction rules decide what an agent still knows late in a long session, why every summary is a lossy write, and how to pin the facts that must survive.

70 min 2 videos 3 exercises 7-question quiz Answers
Setup for the exercises:Install Claude CodePython with uv

By the end of this lesson you can

  • Explain what threshold compaction, on-demand compaction and context editing each remove, keep and rewrite on the Claude API
  • Predict what survives compaction in Claude Code, and move instructions that must persist out of the conversation
  • Compute how the chance of a detail surviving falls with repeated compaction, and state the assumption behind the calculation
  • Write a compaction instruction for a long-running agent that preserves the categories of fact later steps need
  • Pin critical case state outside the summarised history so it is re-injected on every call

On this page

  • Intuition: the notepad and the whiteboard
  • Three ways the window forgets
  • Compaction on the Claude API
  • Context editing and the memory warning
  • What survives compaction in Claude Code
  • A worked example: summaries of summaries
  • Pin, don't hope
  • Misconceptions and limits
  • Connections
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01Intuition: the notepad and the whiteboard
  2. 02Three ways the window forgets
  3. 03Compaction on the Claude API
  4. 04Context editing and the memory warning
  5. 05What survives compaction in Claude Code
  6. 06A worked example: summaries of summaries
  7. 07Misconceptions and limits
  8. 08Connections
  9. 09Summary

Sources & further reading

  • MemGPT: Towards LLMs as Operating SystemsPaper · Packer et al. · 2023Section 2.2: the queue manager's memory-pressure warning, flush and recursive summary of evicted messages, the design that server-side compaction and context editing now productise.
  • Managing context on the Claude Developer PlatformLab research · Anthropic · 2025Anthropic's internal evaluation of context editing and the memory tool on agentic search: the numbers quoted in this lesson, with the caveat that they are the vendor's own.
  • Effective context engineering for AI agentsLab research · Anthropic · 2025The compaction section's advice to tune a compaction prompt for recall first and precision second.
  • Compaction overview (Claude API docs)Docs · AnthropicCompares compaction on demand, compaction at a token threshold and client-side summarisation: who decides when, what you send back, and whether recent turns stay word for word.
  • Compaction at a token threshold (Claude API docs)Docs · AnthropicThe compact_20260112 edit: 150,000-token default trigger, 50,000 minimum, the default summary prompt, custom instructions that replace it, and pause_after_compaction.
  • Context editing (Claude API docs)Docs · AnthropicTool-result and thinking-block clearing, their parameters and defaults, and the automatic warning that lets Claude save to the memory tool before results are cleared.
  • Explore the context window (Claude Code docs)Docs · AnthropicThe 'What survives compaction' table: what Claude Code re-injects from disk, reloads on demand, re-reads, truncates or summarises away.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 9 more sections
  • 3 hands-on exercises
  • A 7-question quiz
  • Progress, quiz scores and bookmarks