Skip to slide
Chapter 5 · Context Engineering and Memory
40 / 191

CHAPTER 05 · Context Engineering and Memory · 3 / 11

Reference, don't embed

A powerful pattern for document- or data-heavy agents: don't dump content into context; reference it and let the model pull what it needs via tools. Instead of pasting five documents into the prompt, give the model short handles ("doc-0", "doc-1") and a read_document tool. The model reads only what the task requires.

This has three benefits:

  1. Smaller prompts: you pay for content only when it's actually used.
  2. Forced grounding: the model must explicitly fetch content, which makes it engage with the real text rather than half-remembered training data.
  3. Freshness: referencing always pulls the current version, avoiding stale content (see below).

Use short, stable, human-meaningless-but-model-friendly labels for the handles, assigned deterministically, so the model can reference them reliably and can only reference things that actually exist.

← → arrow keys work too