← All articles

Felix Tay ·

Why your agent forgets

I built an OpenClaw clone inside my Claude Code.

I wanted to save on API credits.

(And I succeeded - I saved $8,400 in API costs this month)

It went swimmingly.

But eventually, I came across a specific problem most OpenClaw users don’t even know they faced.

Context Compaction.

We assume that if we paste a rule into the chat, the AI will remember it forever.

But as the conversation grows, the model compresses the middle.

Your "perfect instructions" from the start of the chat get fuzzy.

Eventually, the agent starts hallucinating because it literally cannot recall the specific constraint you gave it 40 turns ago.

This is why "promptic" enforcement fails.
You are relying on the AI to remember to be safe.

So I built a "mechanical" enforcement system instead.

And that, turns out, is the key to security.

I wrote a script that forces the agent to check a specific file before it executes any command.

It doesn't matter how long the chat gets.
It doesn't matter if the context compresses.
The check is hard-coded into the execution loop.

If the file says "No," the agent physically cannot say "Yes."

I recorded a full tutorial on how I built this.

It shows you exactly I set up my own OpenClaw clone in Claude Code that runs on my Claude subscription.

Here is the full engineering breakdown.

Link: https://youtu.be/CXDaGh9W5NM 

FELIX


More from the NLC blog →