DeepLearning.AI announced a new short course this week: Agent Harness Engineering, taught by Andrew Ng and Rohit Prasad. The premise is one sentence long — build an agent by wrapping a large language model with a harness — and it names the part of agent building that most demos skip entirely.
The model is the easy part. You call an API, you get text back. The hard part is everything around the call: deciding what the model is allowed to do, what it is allowed to see, when to stop it, and what it should remember next time. That surrounding code is the harness. The course's argument is that the harness, not the model, is what turns a demo into something you would run on your own files.
The loop is the whole agent
Strip an agent down and you get a loop:
- Call the model with the current state of the task.
- Read what it wants to do next — a tool call, a question, or a finished answer.
- Run the tool, feed the result back in, and repeat.
Swap the instructions and the tools and you get a different agent: a coding agent with a file editor and a test runner, a support agent with a ticket search and a refund tool, a file organizer with a move command. The loop stays the same. That is the first lesson worth internalizing, because it reframes where your engineering effort should go. You do not need a better model to get a better agent. You usually need a better loop around the model you already have.
The course builds its example the same way: an agent that sorts a messy Downloads folder into subfolders. It is deliberately boring. A Downloads folder has everything that makes agents scary in miniature — files you care about, write access, and a user with firm opinions about where things belong. If your harness cannot be trusted with that, it cannot be trusted with anything bigger.
Four parts, and only one of them is the model
A working harness has four jobs, and the model does exactly one of them.
The loop. The harness owns the while-loop: call, act, observe, repeat — with a hard step cap. The cap matters more than it looks. Without one, a confused model retries the same failing tool call until your budget or your patience runs out. A step cap turns "the agent is stuck" from an open-ended bill into a bounded, diagnosable failure.
The tools. Tools should be narrow, typed, and boring. A tool called move_file(source, destination) is auditable; a tool called run_anything(command) is a loaded gun pointed at your filesystem. The harness decides which tools exist, validates their arguments before they run, and checks their results before they reach the model. A tool that returns an error message containing a secret has just leaked that secret into the model's context — unless the harness redacts it first.
The guardrails. This is the part the course spends real time on, and it is the part most home-built agents skip. Three rules:
- Mask secrets before the model sees them. A prompt telling the model "don't reveal this key" only works once the key is already in the context. A masking layer in code keeps it from getting there at all.
- Ask before irreversible actions. Moving a confidential file, deleting a folder, sending a message — these need a human yes, not a model yes.
- Sandbox what the agent runs. Commands and file tools should run in a box that holds only the session's folders: no keys, no other files, no open network. Then a prompt injection that reaches a command lands somewhere harmless.
The memory. The agent asks once how you want files organized, then reuses the answer. That is preference memory — small, stable, easy. The harder kind is progress memory: what the agent already tried, what failed, where it left off. Andrew Ng wrote in November that long-running agents need a memory architecture of their own, for example one that compacts the context when it grows too long. Preferences are a settings file. Progress is a design problem, and it is where most agents quietly fall apart on long tasks.
A minimal harness, in about thirty lines
You do not need a framework to see the shape of it. The whole idea fits in a loop you could write in an afternoon:
def run_agent(task, tools, model, max_steps=20): messages = [{"role": "user", "content": task}] for step in range(max_steps): reply = model.chat(messages) messages.append(reply) if reply.is_final_answer: return reply.text call = reply.tool_call # Guardrail: irreversible tools need a human yes. if tools[call.name].irreversible and not ask_user(call): messages.append({"role": "tool", "content": "User declined."}) continue # Guardrail: scrub secrets from tool output before it # reaches the model. result = redact_secrets(tools[call.name].run(call.args)) messages.append({"role": "tool", "content": result}) return "Stopped after 20 steps without finishing." There is nothing clever here, and that is the point. The loop, the step cap, the approval check, and the redaction are all in plain sight. When something goes wrong you can read the harness and find out why, which is more than you can say for most agent frameworks. The OpenWorker Harness SDK — the open-source project behind the course, MIT-licensed, with just over 20,000 GitHub stars — is essentially this shape with the rough edges sanded off: approvals, audit trails, sandboxing, and durable sessions included.
What a harness actually prevents
Three failures show up in almost every agent that ships without one:
The runaway loop. No step cap, no progress check. The model retries a failing tool, slightly reworded, twenty times. You find out from the invoice.
The leaked secret. A tool returns a file or an error that contains an API key. The model now holds it in context, and the next tool call can send it anywhere. Masking at the harness layer is the only fix that works reliably, because it happens before the model ever sees the value.
The amnesia. The agent asks how you like your files organized on Monday, and asks again on Tuesday, and again on Wednesday. Each re-ask is a small tax on trust. Preference memory is cheap to add and expensive to skip.
Notice what none of these failures are: a model problem. A stronger model loops more eloquently, leaks more fluently, and forgets just as completely. The harness is where reliability lives.
The honest limits
A harness is not magic, and the course does not pretend otherwise. A few things worth saying plainly:
- Guardrails are code, not guarantees. A reviewer model that approves routine actions can be fooled, and an approval gate only works if the human actually reads what they are approving. Approval fatigue is real: if everything needs a yes, people start clicking yes to everything, and the leash is gone. The useful question is not "did we add approvals" but "which actions genuinely need one."
- A harness cannot fix a weak model. It can bound the damage, retry the failure, and surface the error. It cannot make a model that misunderstands the task understand it.
- Memory is still the open problem. The course's own memory lesson is five minutes long, and that is honest: remembering a preference is easy; remembering what was tried, what worked, and what to do differently next run is the part the field has not solved yet. If you are building agents that run for hours, that is where your hardest thinking should go.
Where to start
If you want the guided version, the course is about an hour long, free to audit, and built around that one Downloads-folder agent — loop, guardrails, memory, and a practice build where you assemble it yourself. If you want the code, the OpenWorker Harness SDK is on GitHub under andrewyng/openworker, and the install is one line: npm install @openworkerai/harness-sdk.
Either way, the takeaway is the same. The next time an agent demo impresses you, ask what the harness looks like. A model that can call tools is a party trick. A loop with a step cap, a redaction layer, an approval gate, and a memory is a tool you can hand to a real user. The difference between the two is not the model. It is the code around it.
— Davis George · zhuan.xyz
