What is context engineering and how does it differ from prompt engineering?
571 views
40 of 83
1
The problem
Question presented to candidate:
"Lately people say context engineering instead of prompt engineering. What is context engineering, how is it different from writing a good prompt, and what does it look like in a real agent or RAG system?"
What a strong answer should cover:
Prompt engineering is crafting the instruction text; context engineering is designing everything the model sees at each step (instructions, tool definitions, retrieved documents, memory, conversation history, tool results) and the system that assembles it
The context window is a finite budget, and quality falls as it fills with irrelevant or stale material, well before the hard limit (context rot, lost in the middle), so every item must earn its tokens
The main moves: write (keep notes and state outside the window), select (retrieve only what is relevant, load only the tools needed), compress (summarise old turns, trim tool output), isolate (sub-agents with their own clean context)
Ordering and stability: stable content first for caching, the question last, important material at the edges, a reserve for the output
It is an engineering discipline with code and evals: measure what was included, what was dropped and why, and test assembly changes like any other change
Clarifying questions expected:
Is this a single-call feature, a RAG system or a multi-step agent?
What is the context budget per call, and what does a typical step currently send?
Code / implementation expected: Optional β a context assembler that ranks, deduplicates and trims candidate items under a token budget is a strong signal.
context-engineering
prompting
rag
memory
2
Try it yourself
Sketch your approach before you read the solution. That is what the interview tests.
Stuck? Get a hint.
A short nudge toward the approach. It will not give the answer away.
3
Solution
Target Audience: Engineers moving from single prompts to RAG systems and agents, who need to explain what changes when "the prompt" becomes a pipeline.
Difficulty: Medium
Verified with: Node 22.22.0 and Python 3.12.3 (a context assembler run over simulated candidate items with given token counts; no real model is called). Origins of the term and published guidance are cited inline, checked October 2026.
How to read this doc: Every idea is explained in plain language first, then tagged with π Interview term: so you also learn the words an interviewer expects. All program output shown was produced by actually running the example; the Verified section quotes it in full.
1. Why This Even Matters β A Story First
You hire a brilliant consultant for one hour. You can spend that hour polishing the wording of your question: "Please analyse our refund process, concis
The solution is hidden so you can try first
13 min read Β· 10 sections
4
Read the code
Assemble one agent step under a token budget: select, dedupe, compress, order