Symptom
Model cites outdated refund policy.
Prompt reflex
“Always use the latest policy.”
Context fix
Retrieval filter on effective_date, evict stale chunks, attach version id in evidence header.
Prompt engineering shapes model behaviour; context engineering orchestrates what the model sees. Know where wording ends and assembly begins.

The on-call engineer gets paged: the sales copilot started refusing discount requests it approved yesterday. Someone "fixed" it by rewriting the system prompt overnight. The rewrite worked in staging. Production still fails — because the CRM snapshot appended to every request now includes a conflicting pricing table from a sandbox org. Nobody changed the instruction. They changed the cargo.
That incident is the boundary in one story. Prompt engineering designs what you tell the model — role, constraints, output format, tone. Context engineering designs what you feed the model — retrieved documents, tool results, history, metadata, and the order they appear in a finite window. Teams collapse the two because both show up in the same API call. Production reliability depends on keeping them separate in ownership, tooling, and incident response.
Prompt engineering covers instructions the model should treat as authoritative for how to respond:
It ends where the prompt author no longer controls the bytes. Dynamic user input, retrieval results, webhook payloads, and conversation history are not prompt engineering — they are inputs to context assembly. You can write "only use provided documents" in the system message. If assembly ships twelve irrelevant documents, the prompt did not fail. The pipeline did.
| Dimension | Prompt engineering | Context engineering |
|---|---|---|
| Primary artefact | System / developer messages | Assembly pipeline + region budgets |
| Changes when | Behaviour or format drifts | Retrieval, memory, or integrations change |
| Typical owner | ML engineer, PM with eval access | Platform / backend engineer |
| Debug signal | A/B prompt versions | Token breakdown, chunk IDs, eviction logs |
| Anti-pattern | Growing one string forever | Pasting tool JSON without summarisation |
Confusing the two produces a predictable failure mode: every context problem becomes a prompt rewrite. The system prompt swells. Policy duplicates across regions. Latency rises. The model still misses the one paragraph that mattered because it was item eleven in an unbounded list.
Context engineering begins when you ask: what enters the window, from where, under what limit, and what gets dropped?
That includes:

A fraud-review workflow illustrates the split. Prompt engineering defines: "Classify this transaction as approve, review, or block. Return JSON with reason codes from the allowlist." Context engineering ensures the model sees the last three transactions, the merchant risk score, and the relevant policy excerpt — not the entire event stream, not raw Kafka messages, not last week's unrelated alerts.
import { createHash } from "node:crypto";
interface AssembledContext {
systemPrompt: string; // prompt engineering owns this string
evidenceBlocks: Evidence[]; // context engineering owns selection + order
packHash: string;
}
interface Evidence {
id: string;
text: string;
score: number;
source: "retrieval" | "tool" | "memory";
}
function assembleContext(
basePrompt: string,
candidates: Evidence[],
budgetTokens: number,
): AssembledContext {
const sorted = [...candidates].sort((a, b) => b.score - a.score);
const kept: Evidence[] = [];
let used = 0;
for (const block of sorted) {
const tokens = estimateTokens(block.text);
if (used + tokens > budgetTokens) break;
kept.push(block);
used += tokens;
}
const evidenceText = kept
.map((b) => `[${b.source}:${b.id}]\n${b.text}`)
.join("\n\n");
const packHash = createHash("sha256")
.update(basePrompt + evidenceText)
.digest("hex")
.slice(0, 12);
return {
systemPrompt: basePrompt,
evidenceBlocks: kept,
packHash,
};
}
Notice basePrompt is stable versioned text. evidenceBlocks varies per request. Mixing them in one undocumented string destroys your ability to trace regressions.
Store prompt_version and context_pack_hash on every trace. When quality drops, you can tell in one query whether instruction text or assembled evidence changed.
Prompt engineering should sit close to product behaviour — what the assistant must never do, what format downstream APIs expect. Context engineering should sit close to data — retrieval indexes, CRM integrations, agent tool wrappers.
When the same person owns both without tooling, you get prompt bloat: retrieval fixes implemented as "also mention X in the system message." When two teams own each side without a contract, you get integration fights: backend ships full JSON blobs; prompt team adds "be concise" and hopes.
The contract between them is an assembly interface:
basePrompt v3.2 with required output schemamerchant_id metadata linelayer: prompt | context before anyone edits textMisdiagnosed as prompt problems
3 scenarios
Symptom
Model cites outdated refund policy.
Prompt reflex
“Always use the latest policy.”
Context fix
Retrieval filter on effective_date, evict stale chunks, attach version id in evidence header.
Symptom
Agent loops re-read the same 200-row spreadsheet every step.
Prompt reflex
“Do not repeat work.”
Context fix
Store sheet summary by reference; pass row ids; cap tool output tokens.
Symptom
Multi-turn chat “forgets” user preferences.
Prompt reflex
“Remember user preferences.”
Context fix
Structured memory slot updated by a separate extraction step, injected under budget.
In each case, prompt edits add words without adding information. Context edits change what the model can actually access.
Not every failure is assembly. Prompt engineering is the correct tool when:
Run a controlled test: freeze assembly from a failing trace, swap only the prompt. If behaviour changes materially, prompt engineering owns the fix. If not, stop editing wording and inspect the pack.
Practically:
systemPrompt in a versioned file or registry — no dynamic concatenation hidden inside itprompt_version and pack_hash before any hotfixYour eval harness should include cases that vary evidence while holding prompts constant, and cases that vary prompts while holding evidence constant. Most teams only test the second. That is why retrieval regressions ship unnoticed.
Teams that formalise context engineering without a big-bang rewrite usually follow this sequence:
Within a sprint you typically see clearer incidents ("evidence region empty" vs "model hallucinated") and faster fixes because the layer is named.
Treat prompt and context docs as separate runbooks. Prompt runbooks cover tone, refusals, and schema version. Context runbooks cover retriever thresholds, eviction order, memory summarisation jobs, and integration field allowlists. Mixing them guarantees every incident becomes a prompt edit.
Prompt engineering shapes model behaviour. Context engineering shapes the information behaviour operates on. The API call merges both, but production ownership should not. Stop treating every missing fact as a prompt rewrite. Start treating every overloaded window as an assembly bug — with budgets, eviction, and traces — and prompt work returns to what it does best: clear instructions on a clean pack.
Be among the first to explore interactive reference architectures, implementation playbooks, and premium engineering resources at launch.
Recommended reading based on this topic.
Context assembly — not model size — limits reliability, latency, and cost in production AI. It is the most under-engineered layer in most stacks.
Read ArticleRicher LLM context improves answers until prefill latency hurts UX. Measure the trade-off between context size, inference time, and product responsiveness.
Read ArticlePrompt patterns that hold up in production: role and contract design, few-shot selection, structured outputs, tool-aware prompts, and context budgets that do not leak.
Read Article