liveBook · Manning

Context writing

As explained in Context Engineering

Context writing is the technique of moving information out of an active prompt into storage while retaining a reference to relevant stored information.

Context writing preserves useful information outside an LLM agent’s active context window so the agent can recover it later. The prompt remains a compact working surface containing current state, references, and information needed for the next step; full-fidelity history stays in external storage. section 7.3

Writing is one part of context management. Selection decides what belongs in the active prompt; writing preserves useful material that does not need to remain there. An agent can recover stored information through a tool call, retrieval, or a direct file read. section 7.2.2 section 7.3

Figure 7.1 Context is managed through four complementary techniques: selection chooses relevant tokens for the active prompt, writing persists state to external storage, compression condenses verbose history, and isolation divides complex tasks across separate context windows
context management v6

The four techniques address different context-management pressures: selection, external persistence, compression, and isolation. section 7.1

Storage choices depend on what the agent needs to preserve and how it will retrieve it:

  • Vector databases support semantic similarity search across historical interactions and notes; graph databases preserve entity relationships and task dependencies. section 7.3.2
  • Relational databases provide schema integrity, filtering, and auditability; object stores hold large binary payloads and raw documents. section 7.3.2
  • Working scratchpads hold temporary artifacts such as partial calculations, checklists, and plans. An agent can re-read and update them as structured JSON or sectioned Markdown. section 7.3.2

Offloading an order history

A customer support assistant retrieves an extensive order history, stores the full record externally, and keeps only a reference pointer and the active order ID in the prompt. The full history remains available without being carried into every model call. section 7.3.2

Writing and compression relieve context pressure differently. Writing first moves material intact into storage; compression discards detail to reduce the active context. Compressing before writing can permanently destroy recoverable state. If the active working set is still too large after offloading, compression may still be necessary. section 7.3 section 7.3.2

How Context Engineering covers it

How deep it goes
Explains offloading, retrieval, scratchpads, and storage access patterns without a detailed implementation.
Examples
Uses a customer support assistant that stores a full order history while retaining its reference and active order ID in the prompt.
What you can do after
Evaluate storage and retrieval options for preserving recoverable agent context outside the active prompt.
How it connects
Connects context writing with context selection, context compression, and context isolation as complementary management techniques.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Context Engineering. The section links point to the parts of the book it draws on.