All field notes

Context engineering: decide what survives

Separate working context, run state, durable memory, and evidence before adding more tokens.

Published Documentation reviewed

context-engineering, memory, compaction

Context engineering is the work of selecting and maintaining the information available at each decision. Anthropic’s context engineering guide discusses retrieval, compaction, structured notes, and context isolation as techniques for longer tasks.

Four stores with different jobs

Use this proposed layout to review a research or coding agent:

  • Working context: the current objective, relevant instructions, selected evidence, and recent observations sent to the model.
  • Run state: task status, pending actions, completed operations, budgets, and artifact identifiers. The runtime owns it.
  • Durable memory: selected information intended to persist across tasks, with an owner, provenance, retention rule, and correction path.
  • Evidence store: original documents, logs, and outputs that a summary can reference and a reviewer can inspect.

Do not make a conversational summary the sole record of which external actions occurred. A sentence can be compressed away or become ambiguous; an operation record should remain queryable.

Compact with a recovery contract

Ask what a replacement session would need to continue correctly. Here is an example handoff artifact:

{
  "objective": "repair the date parser",
  "workspace_revision": "r2",
  "completed": ["reproduced the month-offset failure"],
  "pending": ["test the proposed patch"],
  "evidence": ["artifact://test-run-17"],
  "constraints": ["do not publish changes"],
  "next_action": "run the parser regression suite"
}

Test the artifact by starting a fresh session with only the persisted state and referenced evidence. Check whether it repeats completed work, loses a constraint, or mistakes a proposal for an executed action.

Context length is only one constraint

Current Claude context documentation distinguishes context capacity from the usefulness of the material inside it and describes server-side compaction. It also states that supported 1M windows are available without the old beta header or a separate long-context price tier. Check the model and hosting platform you use.

Prompt caching changes processing cost; cached tokens still occupy context. It does not resolve missing evidence, incorrect memory, or contradictory instructions.

LangGraph persistence makes a useful implementation distinction between thread checkpoints and stores shared across threads. Choose the scope explicitly before putting user-specific facts in memory.

Design exercise: remove half the working context from a saved run. Record which decisions deteriorate, then restore the smallest useful evidence set. Treat the result as a workload-specific measurement.