Write Stage — Creating Context: Memory, Retrieved Docs, Tool Results, History

~12 min read

Writing context means saving information OUTSIDE the active context window so it can help an agent perform a task later — to long-term memory, short-term memory, or a state object, rather than trying to keep everything live at once.

Write Stage — Creating Context: Memory, Retrieved Docs, Tool Results, History is a Pro topic

Sign in, then upgrade to Pro or Power to unlock this topic and the full AI Engineering curriculum.

Key points

  • Writing context means saving information OUTSIDE the active context window, so it's available for later steps or later sessions
  • 3 write destinations: long-term memory (across sessions), short-term memory (within a session), and a state object (multi-step task progress)
  • Worth writing: memory outputs, retrieved documents, tool results, and relevant conversation history — not everything indiscriminately
  • Being selective at write time reduces the cleanup burden the later Compress stage would otherwise have to do
  • Writing is the foundation stage — there's nothing to Select, Compress, or Isolate later if nothing was durably written first