Where Prompt Engineering Ends: Context, Harnesses, and Loops
A prompt is a spark, not an engine. The spark still matters — it just cannot carry the machine.

Key topics
A prompt is a spark, not an engine. The spark still matters — it just cannot carry the machine.
You have revised the instruction four times. The first revision fixed the failing case. The second fixed a different case and quietly broke the first. The third held for a week, then started failing on inputs you never saw in the eval set. The fourth is sitting in a branch, and nobody on the team is confident it will hold either.
The instinct at this point is to rewrite the prompt again. That instinct is not stupid — wording is the cheapest thing to change, and for a long time it was the only thing. But the question underneath "should I rewrite the prompt?" is not a wording question. It is a diagnosis question: which layer actually owns this failure?
There are four layers worth naming, and each one subsumes the previous rather than replacing it. Instructions. Context assembly. Harness. Loop. The engineering judgment is not "which layer is obsolete." It is "which layer is asking for the fix."
The Revision Reflex and Why It Stops Working
Every behavioral failure looks like a wording problem because wording is the only lever most teams have ever pulled. The model produced the wrong thing, so you tell it more clearly what the right thing is. Sometimes that works. That is exactly why the reflex is so hard to break.
Grant the narrow case first, because it is real. If your call is single-turn, task-isolated, and stateless — a classification, an extraction, a rewrite, a structured summary — then you genuinely are looking at an instruction problem. Prompt engineering is not dead. It is scoped. The prompt contract, the example set, the output schema, the acceptance criteria: all of that is assumed prior work here, and it still earns its keep inside that boundary.
The reflex breaks when the symptom changes shape. Watch for two signals in particular:
- Whack-a-mole revisions. A change that fixes one case regresses two others. You are no longer improving the instruction; you are trading one failure distribution for another.
- Eval overfitting. The fix holds on the eval set and stops holding the moment real inputs widen. The prompt was tuned to the cases you could see, and the cases you could not see were never the same problem.
When either signal shows up, the model is not under-instructed. It is under-supported. Something around the prompt — what it knows, what it can do, how it decides it is finished — is doing work that instructions cannot do.
The invariant to carry through the rest of this article: each layer subsumes the previous one. The question is never "which layer is obsolete." It is "which layer owns this failure."
Four Layers, Four Failure Signatures
Before the deep dive, here is the lookup table. Read it as a symptom-to-layer map, not a maturity model — all four layers coexist in a single production system, and a mature system has all four working at once.
| Layer | What it decides | Failure signature | The fix lives in |
|---|---|---|---|
| Instructions | What and how to ask | Inconsistent quality on inputs the model can already handle | Wording, structure, contract |
| Context assembly | What the model knows when it answers | Confident reasoning over wrong, stale, or missing information | Selection, ordering, compression, freshness |
| Harness | What environment, tools, and limits the agent has | Good instructions and good context, still unpredictable at scale | Tools, hooks, middleware, environment knowledge |
| Loop | What system finds, runs, verifies, and remembers work | No stopping rule, verification that cannot fail, memory that never updates | Trigger, goal, verification, stopping rule, memory |
The asymmetry in this table is the part worth internalizing. A well-crafted prompt inside badly assembled context still fails. A mediocre prompt inside well-assembled context often succeeds. That is not a slogan about which discipline is fashionable — it is a statement about where the leverage sits when the system gets complex.
The Ownership Rule
The layers overlap in practice, so you need one test to assign an artifact to its owner before you start moving code around:
- Context controls the information payload for a single step.
- Harness controls capabilities, interception, policy, and the execution environment.
- Loop controls recurrence, terminal conditions, and cross-step state.
Apply it to a concrete case. A deterministic verification hook that fires before the agent exits is harness control serving a loop requirement. The hook is the mechanism (harness); the requirement that the agent cannot declare itself done without a check is the loop's stopping rule. When you know which side owns the requirement, you know which side to change when it breaks.
Knowledge check
Check your understanding
Answer this question before you continue.
When the Failure Is Context Assembly
Prompt engineering is deciding what and how to ask. Context engineering is deciding what the model knows when it answers. Those are different jobs, and the second one has a maintenance cost the first one does not.
The failure mode has a name worth using: context rot. It shows up when a session, agent, or workflow becomes overloaded with stale summaries, repeated instructions, conflicting decisions, irrelevant files, and buried requirements. The right information may technically be present. It is just surrounded by clutter, and the model's reliability degrades anyway. The can opener is in the drawer. Nobody is getting dinner.
Two tells that you have hit the context-assembly ceiling:
- The glue-code tell. Every workflow branch needs hand-crafted prompt snippets, manual summaries, and ad hoc formatting. When the context has to be assembled by hand for each step, you are not doing prompt engineering anymore — you are doing manual context engineering, and it does not scale.
- The maintenance tell. Context that must be manually kept in sync with a changing schema, dataset, or business rule will drift from what is actually running. The documentation says one thing. Production does another. The gap widens silently.
The practical consequence: before you blame the model or rewrite the instruction, measure retrieval and context-selection quality. If the model is reasoning confidently over the wrong facts, no amount of wording will save you.
One boundary matters here. Context engineering is not a better prompt. It is the system around the prompt, and it carries its own maintenance cost. You are trading cheap-per-attempt prompt edits for expensive-up-front context architecture that removes recurring manual intervention. That trade is worth it when the failure is genuinely about what the model knows. It is a waste when the failure is about how you asked.
Knowledge check
Check your understanding
Answer this question before you continue.
When the Failure Is the Harness
A harness is the operational environment around the model: system prompt delivery, tools, hooks and middleware, skills, sub-agent delegation, memory systems. If context engineering decides what the model knows, harness engineering decides what the agent can do and how the environment pushes back.
Most harness engineering is context engineering on behalf of the agent. The agent needs environment knowledge — directory structure, available tools, constraints, evaluation criteria — delivered so it can self-direct. The more the agent knows about its environment, the better it can autonomously plan.
The signature failure that points here: the agent has good instructions and good context but still fails unpredictably at scale, or repeats a broken approach many times in a row. That second pattern is common enough to have a name — the doom loop, where the agent makes small variations to the same failed approach ten or more times.
Two mechanisms are worth knowing because they show what harness engineering actually does:
Deterministic context injection. Middleware that intercepts the agent before it exits and forces a verification pass against the task spec. The agent does not get to declare itself done without running the check. This is a hook, not a prompt — it fires on the exit path regardless of what the model believes about its own completeness.
Loop-detection middleware. Track per-file or per-step edit counts via tool-call hooks. After N edits to the same file, inject a signal like "consider reconsidering your approach." The honest limit: the model can ignore it. If the model thinks it is correct, it may continue down the same path. The hook raises the odds of recovery; it does not guarantee it.
One more property matters operationally: harnesses are model-specific. The principles generalize — good context preparation, aggressive verification, environment knowledge — but the tuning does not transfer cleanly between models. A harness tuned for one model can underperform on another until you run a few rounds of iteration for your task.
And the boundary: harness engineering is overkill for single-turn or task-isolated calls. If your call is stateless, you do not need middleware. You need a good prompt and a clean context.
Knowledge check
Check your understanding
Answer this question before you continue.
When the Failure Is the Loop
Three things get conflated under the word "loop," and separating them is most of the clarity:
- An ordinary programming loop.
for,while, iteration in code. Not what we mean. - The harness's internal cycle. The perceive-act-observe plumbing the harness already runs. This is the engine.
- The external loop specification. A bounded, reusable artifact a human hands to the harness so the agent works on its own. This is the pilot.
The loop specification has an anatomy: a trigger, a goal, a verification step, a stopping rule, and a memory. The loop layer asks what system you build so the agent finds, runs, verifies, and remembers work without a human in the middle of each step.
This is not a replacement for prompting. A loop is a prompt repeated with scaffolding around it. Two tools, not one successor. Learning to use the wrench does not mean throwing away the screwdriver.
Failure signatures that belong at this layer:
- No stopping rule. The agent runs until something external kills it, or stops at an arbitrary point.
- Verification that cannot fail. A check that always passes is not a check. It is ceremony.
- Memory that never updates. The agent repeats work it already did because nothing recorded the result.
- A goal the agent cannot recognize as complete. The work is done, but the agent has no way to know that.
One fragility deserves naming because it is where loop engineering earns or loses its value: self-correction and model-as-judge verification can be unreliable. A model asked to grade its own work is biased toward its first plausible solution. If your verification step is "ask the model if it did well," you have built a loop that cannot fail — which means it cannot help.
Knowledge check
Check your understanding
Answer this question before you continue.
A Diagnostic Pass You Can Run Today
Here is the ordered procedure. Run it against one real failing case, not the aggregate dashboard. The point is to produce evidence that assigns the failure to a layer, so each step ends with an observable you can read off a trace.
| Layer | Trace artifact to inspect | Pass condition | Fail condition |
|---|---|---|---|
| Instructions | Rendered messages, output schema | Output matches schema on inputs the model can handle | Schema or quality violations on otherwise adequate inputs |
| Context | Assembled context payload, retrieval sources | Sources are fresh, non-conflicting, and relevant | Stale, duplicated, or conflicting evidence in the payload |
| Harness | Tool schema, permissions, hooks, tool-call outcomes | Required tools available; hooks fire as designed | Missing tools, silent hook failures, environment guessing |
| Loop | Trigger, iteration state, verification result, terminal transition | Verification can fail; terminal state is reachable | Always-passing checks; no reachable stop condition |
Step 1 — Freeze the prompt and re-run the failing case. If the failure reproduces, move to Step 2. If it does not, you have a variance branch, not a stopping point. Capture several traces under fixed inputs and compare four things across runs: the assembled context, tool availability and calls, model settings, and loop state. Whichever of those changes between runs is the variable to classify — a shifting context payload points at context assembly, a tool that intermittently fails points at the harness, and a loop that advances differently each run points at loop state. Nondeterminism is a cross-cutting symptom, not a layer. It usually means you need harness controls or better evaluation before prompt revision will tell you anything.
Step 2 — Inspect the actual assembled context for that call. Not the context you intended to send. The context that was sent. Look for staleness, duplication, conflicting decisions, and buried requirements. This is where context rot lives.
Step 3 — Check whether the agent had the environment knowledge and tools it needed. Did it know the directory structure? Did it have the tool it needed? Did any verification hook fire? If the agent was guessing at its environment, the failure is harness-level.
Step 4 — Check whether the system had a stopping rule and a memory. Or was it relying on the model to decide it was done? If the agent had no way to recognize completion, the failure is loop-level.
Step 5 — Only after the first four come back clean, revise the instruction.
The emphasis on trace-level inspection over aggregate metrics is deliberate. Per-call cost, token counts, and tool-call sequences reveal which layer failed. A dashboard average hides the one call that broke. Trace-level cost reconciliation beats coarse spend totals because the trace shows you the sequence, and the sequence shows you the layer.
A short worked example. A support agent starts giving wrong refund policy answers. The team's first move is to rewrite the system prompt with more explicit policy language. It does not help. Trace inspection shows the retrieval step is returning a policy document from eighteen months ago — the current policy exists in the index, but the stale one ranks higher. The prompt was never the problem. The context assembly was. The fix is a freshness filter on retrieval, not a paragraph of new instructions.
Choosing the Wrong Layer Is the Expensive Mistake
The cost asymmetry is the whole argument. Prompt revisions are cheap per attempt but compound into unmaintainable glue code — endless summaries, hand-crafted snippets, ad hoc logic for every branch. Harness and loop work is expensive up front but removes recurring manual intervention. You pay once or you pay forever.
Here is the when-to-use guidance, layer by layer:
Prompt engineering is still correct when: the task is single-turn, task-isolated, or conversational, and the failure is genuinely about output quality. This is not a consolation prize. It is the right tool for a large class of calls.
Context engineering is the right investment when: agents reason over retrieved information, RAG returns irrelevant results, or the model confidently grounds on incorrect facts. The symptom is wrong knowledge, not wrong wording.
Harness engineering is the right investment when: you run autonomous multi-step agents in production, context is solid, and behavior is still unpredictable at scale. The symptom is unpredictable action despite good knowledge.
Loop engineering is the right investment when: repeated work is currently shepherded by a human step by step. The symptom is a human in the middle of every cycle.
The anti-pattern to avoid: building a loop to compensate for a context problem, or a harness to compensate for an instruction problem. You pay the complexity cost and keep the original failure. The new layer does not fix the old one — it just adds surface area for the same bug to hide in.
The Decision Rule
Before the next prompt revision, name the layer that owns the failure. That is the whole discipline. Not "is prompt engineering dead" — it is not, it is scoped — but "which layer is this failure asking for."
The durable mental model is nested tools. Prompt, context, harness, loop. Each one subsumes the previous. Each one has a failure signature. Each one has a boundary where it becomes overkill. The engineering judgment is knowing which one the failure is asking for, and having the discipline to check the cheap layers before reaching for the expensive one.
Your next action: take one currently failing case. Freeze the prompt. Inspect the assembled context and the trace for that single call. Look for staleness, missing environment knowledge, and the absence of a stopping rule. If any of the first four layers shows a defect, you have found the fix — and it was never in the wording.
Knowledge check
Final check
Finish the article by checking the ideas you just learned.
References
Research updated Sep 11, 2026


