Context Engineering
What the AI sees matters more than how you ask
The sequel to prompt engineering: managing what information goes into the model's window and how it's structured. Organised by the Write · Select · Compress · Isolate framework, with anti-pattern → done-right examples that tie into RAG (Dify) and agents (n8n).
After this chapter you can
→ Decide what to put in the context window — and what to leave out
→ Use retrieval (RAG) to pull only the relevant context
→ Compress long histories and prune noise to fight context rot
→ Isolate concerns across steps and agents for clean context
Write What you put in the window
Give it the source, not just the question Don't ask the model to recall a specific paper from memory — put the actual text in front of it.
✕ What does the 2023 Zhang paper say about CRISPR off-target effects?
✓ Paste the paper text (or attach the PDF) and ask: "Using only this paper, summarize what it reports about off-target effects."
Why it works: A model cannot reliably recall one specific paper from training. Give it the real text and it answers from fact, not a fuzzy memory.
Instructions at the right altitude Not a brittle 2-page rulebook, not a vague one-liner — a handful of strong heuristics.
✕ Be a helpful research assistant. —or— a 2-page list of every edge case and rule.
✓ You are a research assistant for biology students. Be concise, define jargon on first use, prefer primary sources, and say when you are unsure.
Why it works: Over-specified prompts get brittle and hard to maintain; vague ones get generic. A few clear principles steer behavior without micromanaging.
Put key info where the model looks Models attend most to the start and end of the context — not the middle.
✕ Bury the actual task in the middle of three pages of pasted material.
✓ Instruction at the top, the data clearly tagged in the middle, and restate the ask at the end: "Remember: answer only from the text above."
Why it works: Important instructions buried in a long middle get lost ("lost in the middle"). Anchor them at the edges.