Skip to slide
Chapter 3 · How Memory Is Built and Retrieved
20 / 40

CHAPTER 03 · How Memory Is Built and Retrieved · 5 / 7

The agent loop and context tools: the Claude Agent SDK

The "Building agents with the Claude Agent SDK" article approaches memory from a different angle: the overall agent loop and the tools that support it. Its core design principle is "give the agent a computer." By giving the model the same tools a programmer uses (run bash commands, read, write, edit, and search files), it can handle a huge range of work, and the filesystem itself becomes a form of memory and context engineering.

Several features it describes are directly part of the memory picture:

  • Agentic search and the filesystem. The file and folder structure becomes context the agent can pull from. When the agent hits a large file, it uses tools like grep and tail to load only the relevant parts. The article stores past conversations in a folder so the agent can search them, which is episodic memory backed by the filesystem. This is agentic search.
  • Semantic search, used sparingly. The SDK supports semantic search (chunk, embed, query by vector) but recommends starting with agentic search and only adding semantic search if you need faster results, because semantic search is less accurate, harder to maintain, and less transparent.
  • Subagents. A sub-agent runs in its own isolated context window and returns only the relevant result, which both enables parallelism and protects the main agent's context from being clogged by intermediate work. This is the read and manage phases working together.
  • Compaction. When an agent runs a long time, the SDK's compact feature automatically summarizes earlier messages as the context limit approaches, so the agent does not run out of room. This is the manage phase built into the harness.

The article also describes the loop these tools serve: gather context, take action, verify work, repeat. The verification step (rules-based checks, visual feedback, or an LLM-as-a-judge) is what keeps errors from compounding, which matters for memory because an unverified bad result can become a bad memory.

← → arrow keys work too