Skip to lesson

AnthropicClaude Certified Architect – Foundations2026-105.1 Manage conversation context to preserve critical information across long interactions

Context Engineering for AI Agents: Memory vs. Compaction vs. Tool Clearing

Completed by opening the official lab

Why it matters

Section 5.1 is about keeping the facts a long conversation needs. This notebook measures three API primitives against one agent, so you can see which kind of context growth each one addresses.

What to practise

Run a research agent over eight documents, about 320K tokens of tool results, first with no context management. Then enable server-side compaction (compact_20260112), tool-result clearing (clear_tool_uses_20250919 with trigger and keep), and the memory tool (memory_20250818) with a file-backed handler; the two context edits are beta features with their own beta headers. Watch the probe that checks which details survive a compaction summary, what clearing removes from context, and how a second session differs with and without the first session’s /memories files. Try replacing the default summary prompt with your own instructions.

How it fits

Compaction loses the exact figures that 5.1.2 keeps in a separate record, and custom instructions are one way to protect them. Clearing old tool results is the in-context counterpart of 5.1.4’s trimming. Memory files hold state across sessions, which 5.1.1’s history replay can’t do on its own.