NOTES / PART 1 · FOUNDATIONS

02Prompting and context engineering

Deciding what the model sees: instructions, examples, state and memory.

THIS SECTION COVERS

Prompt design, few-shot examples, structured outputs, the context window as a budget, long-context trade-offs, compaction and summarisation, short- and long-term memory.

Related: RAG and retrieval · Harnesses

TOPICS · 7/7 WRITTEN

  1. 02.1Prompt designWriting instructions a model can follow: separate the parts of a prompt, pitch rules at the right altitude, explain the why, and test with a cold reader.
  2. 02.2Few-shot examplesShowing the model what you want: how in-context examples work, what they actually teach, and how to choose three to five good ones.
  3. 02.3Structured outputsGetting machine-readable answers: constrain the response to a JSON schema, validate in code, and retry with the error when it fails.
  4. 02.4The context window as a budgetEverything the model sees competes for one finite window and one finite attention budget. Treat tokens as a scarce resource and keep only high-signal ones.
  5. 02.5Long-context trade-offsWhen to put everything in a huge window and when to retrieve instead: quality, latency and cost all move with length, so decide by measuring.
  6. 02.6Compaction and summarisationKeeping long-running agents inside the window: clear stale tool results, summarise older history, and know what each approach throws away.
  7. 02.7MemoryGiving agents recall beyond one window: working notes, files the agent can read and write, and the OS-style idea of paging information in and out of context.