# Andrew Ng's harness course gives agent memory just five minutes

> The one-hour class teaches the right habit of asking permission, but its guardrail and memory lessons need more reading before an agent reaches a client.

Original: https://fdetimes.net/en/books-courses/andrew-ng-agent-harness-engineering-course/

On November 13, 2026, Andrew Ng wrote [in The Batch](https://www.deeplearning.ai/the-batch/how-to-build-an-agent-harness-in-one-prompt) that long-running agents need a memory architecture of their own, for example one that compacts the context when it grows too long. In the course on agent harnesses that he teaches himself, the "Agent Memory" lesson lasts five minutes.

[Agent Harness Engineering](https://www.deeplearning.ai/courses/agent-harness-engineering) is a Beginner-level short course from DeepLearning.AI that runs 1 hour 3 minutes. Ng's co-instructor is Rohit Prsad (as the course page spells his name); together they built the open-source OpenWorker Harness SDK.

An FDE who finishes the course will be able to build an agent that asks before it acts, but will not yet be ready to put it into a client's production systems. Guardrails and approval call for the OpenAI Agents SDK documentation as well. Memory calls for Ng's letter and Anthropic's engineering post on long-running agents.

Without that extra work on memory, an agent tidying 1,000 files, in a made-up example developed below, could have its context compacted after file 600 and forget the three files the user had refused to let it move.

## A messy Downloads folder makes a good exercise

The whole course revolves around an agent that sorts the Downloads folder into subfolders. The problem is small, but it has everything that worries a client: sensitive data, write access and a user with firm ideas about how things should be organized.

You build it with a coding agent, so there is no code to type yourself. The graded assignment and the certificate of completion belong to the PRO plan.

If you do not type the code, it is easy not to understand it. At a client site, you will have to show the security team the exact lines that block a file from being read. So once the coding agent is done, reread every branch of the checks until you can explain each one.

## Lesson one: mask data before the model sees it

The lesson "Agent Safety: Implementing Guardrails" lasts eight minutes. This part of the course has learners stop the agent from reading sensitive files, mask API keys before the LLM sees them, and ask the user before moving confidential files.

What matters is masking the key before the model reads it. A prompt telling the model not to reveal a key comes into play only once the key is already in the context; a masking layer in code keeps it from getting there at all. Ng's letter also lists keeping credentials away from the LLM as a security control, alongside sandboxing.

The first job at a client: list every path by which data enters the context, including tool results and error messages. Plant a fake key in each path, then search the logs. If the key shows up in even one place, the masking layer is in the wrong position.

## Lesson two: guardrails and approval are separate doors

The [OpenAI Agents SDK documentation](https://developers.openai.com/api/docs/guides/agents/guardrails-approvals) separates two concepts that are easily merged. Guardrails automatically check input, output or tool behavior. Human review pauses the run so that a person or a policy can approve or reject a sensitive action.

Say a client has 1,000 files to move, 20 of them confidential. Ask for approval on every file and the user gets 1,000 questions and tends to click yes out of habit. Ask only when a classifier flags a file as confidential, and if it misses two, the user sees 18 questions while two confidential files are moved without anyone knowing.

Provided it never flags an ordinary file by mistake, that classifier is still right on 998 of 1,000 files, or 99.8%, a fine number for a slide. The number the client needs is the two confidential files in 20 that slipped through, or 10%. Agree on an acceptable miss rate before discussing the design of the approval button.

**Key point:** Measure an agent by the times it should have asked and did not.

Where a guardrail sits can also create a false sense of safety. According to the OpenAI documentation, input guardrails run only for the first agent in the chain, output guardrails only for the agent that produces the final result, and tool guardrails on the function tools they are attached to. If it is the second agent that moves files, put the check on that tool.

What about an agent that runs at night, with nobody at the screen? The [OpenWorker](https://github.com/andrewyng/openworker) desktop app, which is outside the course exercise, does not let such runs approve themselves: requests wait in an inbox until someone answers. The question for the client is who opens that inbox, and which work is allowed to wait.

## Lesson three: preferences are easier to remember than progress

In the course, the agent asks the user once how files should be organized, then reuses the answer in later runs. That is preference memory: little data, and little change. The exercise teaches the right habit, which is never to make the user answer twice.

State memory is harder, and context compaction, the example Ng gives in his letter, shows why. Return to the 1,000 files: after 600, the agent has asked 11 times, and the user has approved eight requests and refused three. At that moment the context fills up and has to be compacted.

If the compacted version keeps only the line "600 files processed, confidential files already asked about," the names of the three refused files are lost. The agent may ask again, which annoys the user. Worse, it may treat those three files as approved and move them.

So write each decision to a file outside the context as soon as the user answers, and have the agent reread that file after every compaction. The test is equally clear: force a compaction at file 600, then check that the eight approved files are not asked about again and that the three refused files are still where they were.

Agents forget just as easily when a job spans several sessions. [Anthropic's engineering post](https://anthropic.com/engineering/effective-harnesses-for-long-running-agents) describes each new session as starting with no memory of what came before; the team uses a claude-progress.txt file together with git history for the handover.

Choosing files and git has another obvious benefit: people can open them and read them.

The table below turns three parts of the course into tests you can run with a client.

| In the exercise | In the client's system | Test |
|---|---|---|
| Masking API keys | Credentials in logs, tickets and tool results | Plant a fake key and search every LLM call |
| Asking before moving confidential files | Approving actions that are hard to reverse | Count confidential actions that got through without a question |
| Remembering how to organize files | Remembering each team's rules and progress | Interrupt midway, open a new session and see whether work is repeated |

## Who should take it, and in what order

The course suits developers who have never built a harness, which is also the audience DeepLearning.AI is targeting. If you already run agents with tools, you can skip it and start with the OpenAI documentation. Newcomers should take the course, read Ng's letter, then use the OpenAI documentation to separate guardrails from approval, and finish with Anthropic's post.

Only after those three sources should you open the OpenWorker repo to look at the code, and take care to pick the right part: the README distinguishes the Desktop App, which uses a Python engine, from the Harness SDK, which has its own Rust engine. The SDK is for people who want to build their own agentic applications on desktop and web.

When job hunting, watch for phrases such as "guardrails," "human-in-the-loop" or "approval workflow" in postings. A demo with the three tests above is more persuasive than the name of a course on a résumé. The line describing it should say how many cases you tried, how many got through and at which layer you fixed them.

One hour is enough to build an agent that asks permission. Your next job is to find out when it forgets to ask.

**Try this week:**

- Take the course, then put a fake API key in the test folder and check the logs to make sure it never entered the LLM's context.
- For an agent you are working on, list the actions that are hard to reverse and write down who approves each one, where, and what happens if nobody answers.
- Shut the agent down midway, open a new session and record what it has forgotten.

## Sources

- [Agent Harness Engineering: Build an agent by wrapping an LLM with a harness - DeepLearning.AI](https://www.deeplearning.ai/courses/agent-harness-engineering)

- [How to Build an Agent Harness in One Prompt](https://www.deeplearning.ai/the-batch/how-to-build-an-agent-harness-in-one-prompt)

- [andrewyng/openworker README (GitHub)](https://raw.githubusercontent.com/andrewyng/openworker/main/README.md)

- [GitHub - andrewyng/openworker](https://github.com/andrewyng/openworker)

- [Guardrails and human review](https://developers.openai.com/api/docs/guides/agents/guardrails-approvals)

- [Effective harnesses for long-running agents](https://anthropic.com/engineering/effective-harnesses-for-long-running-agents)
