Key Takeaway

Prompt engineering is writing and organizing the instructions you give an LLM; context engineering is curating and managing everything the model sees, including tool definitions, retrieved data, history and memory beyond the instructions (Anthropic’s definition). Harness engineering is designing the runtime around the model (tools, loops, verification, permissions, state), and graph engineering is structuring work as a graph of nodes, edges and shared state, LangGraph-style, to fix the flow. The last two are recent terms without a standard definition, so this post summarizes how they’re actually used, with sources.

Read enough about AI agents these days and the list of “something engineering” terms keeps growing. This post defines prompt, context, harness and graph engineering one by one: how they differ, when to use each, and a short example. At the end it briefly adds RAG and evals. Every definition comes from the sources below, and where there’s no source, the post says so.

What exactly does prompt engineering cover?

One-line answer: how to write and organize the instructions you give the model.

  1. Definition: Anthropic describes prompt engineering as “methods for writing and organizing LLM instructions for optimal outcomes” (Anthropic, Effective context engineering for AI agents). Anthropic’s prompt engineering docs point to a separate “Prompting best practices” page for the techniques, from clarity and examples to XML structuring, role prompting, thinking and prompt chaining. The same page advises having success criteria and a way to test against them before you start prompt engineering.

  2. When to use it: it’s the first place to look when a single-call task (summarizing, classifying, transforming) gives inconsistent results or ignores the format. Anthropic’s Building effective agents also notes that for many applications, optimizing a single LLM call with retrieval and in-context examples is enough.

  3. Short example: a prompt that separates role, task and output format (an illustrative example).

<role> You are a reviewer who reads embedded Linux logs.
<task> Pick at most 3 candidate causes of the error in the log below.
<format> For each candidate, quote the exact log line it is based on.
<log>
...
</log>

How is context engineering different from prompt engineering?

One-line answer: if the prompt is the instructions, the context is everything the model sees at inference time, instructions included.

  1. Definition: Anthropic defines context engineering as “the set of strategies for curating and maintaining the optimal set of tokens (information) during LLM inference,” including all the other information that lands in the context outside the prompts, and calls it the natural progression of prompt engineering (Anthropic).
  2. Core principle: the same post says LLMs have a finite attention budget, so good context engineering means finding “the smallest possible set of high-signal tokens” that maximize the likelihood of the desired outcome. For retrieval it describes a “just in time” strategy of holding lightweight identifiers such as file paths and loading data when needed; for long-horizon tasks it describes compaction (summarizing a long conversation and continuing in a fresh context), structured note-taking, and sub-agent architectures.
  3. When to use it / example: multi-turn or long tasks where “what does the model see?” is the problem. For example, letting an agent hold only file paths and read files when needed instead of pasting whole files every turn, or summarizing just the decisions when a conversation gets long, is context engineering.

What is harness engineering, and is there a standard definition?

One-line answer: it’s designing the runtime around the model (tools, loops, verification, permissions, state); there’s no standard definition yet, and the term spread only recently.

How prompt, context and harness nest, alongside the graph

  1. Status of the term: Wikipedia’s Agent harness article says the phrase “harness engineering” emerged in early 2026 and that its attribution is contested (some accounts credit a post by Mitchell Hashimoto, others LangChain’s Vivek Trivedy). So what follows is common usage, not a standard definition.

  2. Common usage: LangChain’s The Anatomy of an Agent Harness sums it up as “Agent = Model + Harness” and describes the harness as “every piece of code, configuration, and execution logic that isn’t the model itself”; a model becomes an agent once a harness gives it state, tool execution, feedback loops and enforceable constraints. The O’Reilly Radar article lists system prompts and rules files, tools and MCP servers, sandboxes, orchestration, hooks and observability (logs, traces) as harness parts. The LangChain post also says “harnesses today are largely delivery mechanisms for good context engineering,” and Wikipedia describes a framing in which the harness is a broader layer that contains prompt and context engineering as parts. So if context is “what to show,” the harness widens the scope to “what to let it do and how to check it.”

  3. When to use it / example: when an agent has to use tools, verify results and retry on failure. Below is an example that shows only the core of a harness (tool loop + deterministic check + step limit) with a fake model; no real API is called.

# Example: the core of a harness = tool loop + verification (fake model, no API)
def fake_model(history):
    # stands in for an LLM: first asks for a tool, then answers
    if not any(m["role"] == "tool" for m in history):
        return {"tool": "add", "args": (2, 3)}
    return {"answer": history[-1]["content"]}

TOOLS = {"add": lambda a, b: a + b}

def verify(answer):            # deterministic check before we accept
    return isinstance(answer, int)

def run(task, max_steps=5):
    history = [{"role": "user", "content": task}]
    for step in range(max_steps):
        out = fake_model(history)
        if "tool" in out:
            result = TOOLS[out["tool"]](*out["args"])
            history.append({"role": "tool", "content": result})
            continue
        if verify(out["answer"]):
            return out["answer"], step + 1
        history.append({"role": "user", "content": "check failed, try again"})
    raise RuntimeError("gave up")

print(run("what is 2 + 3?"))

Actual output from running it on Python 3.13.5 (answer 5, finished at step 2):

(5, 2)

What is graph engineering, and how does it relate to LangGraph?

One-line answer: it’s designing an agent system as a graph of nodes, edges and shared state to control the flow, and this too is a newly coined name.

  1. Status of the term: the LangChain post 3 Years of Graph Engineering with LangGraph introduces “graph engineering” as the latest buzzword out of X, joining prompt, context, harness and loop engineering, and says itself that it isn’t a new idea but the latest name for a well-established approach to building reliable agents. The key point it makes is that a graph lets the builder constrain behavior to intended paths instead of relying solely on the LLM’s judgement.

  2. How LangGraph is built: per the LangGraph Graph API docs, a graph consists of State (a shared snapshot), Nodes (functions that take the state, do work and return updates) and Edges (fixed or conditional transitions that choose the next node). Per the LangChain post, a node can be deterministic code, a single LLM call, a tool call, or a full agent with its own loop. My own interpretation: this is close to drawing out explicitly what Anthropic calls a workflow, where LLMs and tools are orchestrated through predefined code paths (Building effective agents).

  3. When to use it / example: when you want steps and branches fixed up front so the system is predictable and auditable. Below is an example graph with no LLM that loops “write → check → rewrite if it fails.” It really ran on LangGraph 1.2.15.

# Example: a tiny LangGraph state graph (no LLM; nodes are plain functions)
from typing import TypedDict
from langgraph.graph import StateGraph, START, END

class State(TypedDict):
    draft: str
    tries: int

def write(state: State):
    return {"draft": state["draft"] + "!", "tries": state["tries"] + 1}

def check(state: State):
    return "done" if state["draft"].endswith("!!") else "retry"

g = StateGraph(State)
g.add_node("write", write)
g.add_edge(START, "write")
g.add_conditional_edges("write", check, {"retry": "write", "done": END})
app = g.compile()
print(app.invoke({"draft": "hello", "tries": 0}))
{'draft': 'hello!!', 'tries': 2}

Where do RAG and evals fit in this picture?

One-line answer: RAG is a common way to fill the context, and evals are how you measure whether any of the changes above actually helped.

  1. RAG: proposed in Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (2020), it combines a generator with retrieval over external documents. In this post’s terms, it’s one tool of context engineering, deciding what goes into the context.
  2. Evals: “eval engineering” isn’t a standard term either. Anthropic’s Demystifying evals for AI agents splits agent evals into capability evals (what can it do well?) and regression evals (does it still handle what it used to?), and recommends deterministic graders where possible, LLM graders where necessary, and human graders judiciously. Whether you change the prompt or the harness, you need evals to know it was an improvement.

So what should you reach for first, and when?

One-line answer: start with the simplest option and add a layer only when you get stuck.

  1. The four don’t compete; they differ in scope. Putting the sources together: the prompt is part of the context (Anthropic), managing the context is one of the harness’s jobs (LangChain, Wikipedia), and a graph is a structure that fixes a multi-step flow, whose nodes can hold an LLM call or a whole agent.

When to use each kind of engineering

  1. Anthropic recommends finding the simplest solution possible and increasing complexity only when needed (Building effective agents). As an order: ① refine the prompt, ② tidy the context (retrieval, memory), ③ build a harness if you need tools and verification loops, ④ fix the flow as a graph if it must be predictable. Check the effect of each step with evals.

Which sources were used?