DEV Community

Qingfeng
Qingfeng

Posted on Edited on

My AI assistant said "done." Then my config was gone.

Why long sessions quietly lose the constraints you gave them — and the three habits that fixed it for me.

Two hours into a session with an AI coding agent, I asked a lazy question: "what was that file called again?"

It answered immediately, in a confident voice, with a filename that did not exist. It wasn't lying. It genuinely didn't remember. The conversation had grown past the context window, and the earlier part of it had been compressed into a few lines of summary. The details were gone. The tone of certainty was not.

Most people meet this the same way: they decide the model is "dumb today" and move on. I did too, until it cost me something.

The failure that made me change my workflow

I was editing a config file. Ten minutes earlier I had said, clearly: don't touch this parameter.

Two hours later, the parameter was touched. When I scrolled back, my instruction was right there in the transcript. But from the model's point of view at that moment, my instruction no longer existed. What existed was a summary line: "user asked not to change key parameters (specifics not specified)."

That is the whole problem in one sentence. The thing you said is in the log. It is not in the working memory. Summaries preserve intent and drop specifics, and specifics are exactly what you needed kept.

Three habits that fixed it for me

None of these are clever. All of them are cheap.

1. Put constraints in a file, not in the chat.

If a rule matters for the next two hours, it does not belong in a message that will be compressed. It belongs in a file the agent reads before it acts — CONSTRAINTS.md, AGENTS.md, a comment header in the target module. Anything the agent can re-read is durable. Anything it must "remember" is not.

2. Make every step leave a file on disk.

If each step's output is a file, the next step's input is a file, and nothing needs to be recalled. Recollection is replaced with reading. This single change kills a whole class of "it forgot what the previous step produced" failures, because there is no recall step to fail.

3. Ask for the plan before it touches anything.

Not "go do it" but "which tools, which files, which lines, and why." Reviewing a plan is cheap; reviewing a diff that ran across forty files is not. It also catches the compression problem early, because a plan that references a nonexistent constraint reveals the gap before it costs you anything.

The test I now use

I judge an AI workflow by one question:

Start over from scratch — can it reproduce the same process?

Not the same wording. The same process: same files touched, same checks, same stops. If yes, the work is deliverable and reviewable. If no, you have a very productive assistant that cannot be trusted with anything you'd have to explain to a colleague.

Reproducibility is not a nice-to-have. It is the line between a toy and a tool.

What I actually run

I use an agent called GAL (agent-home.ai). Two things about it address the problem above rather than hiding it:

  • Per-call permission. Approval is not an all-session switch. Each tool call can be authorized on its own, so a mistake in step 3 doesn't inherit access from step 1.
  • Local and logged. It runs on your machine, and every action leaves a record. When the context is compressed, the facts are still on disk and can be pulled back out.

It is one binary, Windows/Mac/Linux. The release repo is here: https://github.com/gal-agent/gal-release

The uncomfortable takeaway

We talk about agent reliability as a model problem. Much of it is a memory architecture problem that we keep trying to solve with better prompting. The fix is duller than that: write the rules down, put the artifacts on disk, review the plan, and check that the process reproduces.

If your assistant says "I remember" — ask it what exactly. The answer is often "a summary of what you said," and that summary is not something you should build on.


Related notes from the same build

Top comments (6)

Collapse
 
galagent profile image
Qingfeng •

@alicexixi85 Exactly, and that framing is the useful one. Two things bit me when I built it this way:

  1. Sideways writes. Comparing keys before/after a hooked write misses the case where something else touches the same file: a formatter, a code generator, git checkout, another tool. The check has to hang off "any write to this path", not off "the tool I expected to be the writer".

  2. Silent skip. If the before/after comparison can't read one side (file missing, permission denied, parse error), many implementations fall through as "no diff, so no change". Absence of evidence becomes approval. Mine now fails closed and hands the model the reason instead of quietly continuing.

The payoff is exactly what you said: the rule stops depending on what survived the summary, because there is no recall step left to lose it.

Collapse
 
alicexixi85 profile image
Dejun (Alice) Chen •

On sideways writes, I'd stop trying to catch the writer at all. git checkout and a formatter will never call your hook, but none of them can skip the moment the value gets used. Checking the pinned keys against a stored copy at session start and before any tool call that reads that config catches every writer, including ones nobody has listed yet. The hook on known writes then becomes the fast path that gives a clearer error, not the guarantee.

Collapse
 
galagent profile image
Qingfeng •

Agreed — a file the agent reads is still a request, not an enforcement. The rule has to sit in the execution path, not in the context.

Close to your hook idea, in three layers:

  • a gate that runs before the tool executes and can deny the call outright; if the gate cannot produce a decision (script missing, non-zero exit), the call is refused — a decision that could not be obtained is never an approval
  • for config writes, a snapshot taken before the first irreversible write, so the diff is recoverable even when the check is wrong
  • the deny reason is returned to the model, so it re-plans instead of retrying blind

The subtle part of your last sentence: it only holds if the check does not parse the model's intent. Grepping the plan text for forbidden paths is useless — a rephrase defeats it. Comparing the keys actually touched in the tool call is what made it dependable.

One addition: document the checker's own failure mode. If the checker errors, most wrappers quietly let the write through.

Collapse
 
galagent profile image
Qingfeng •

@alicexixi85 Agreed, and the reframe is worth more than the hook itself: read-time is a chokepoint, write-time is a guess about who the writers are. Three things bit me when I moved the check there.

  1. It only works if reads are funnelled. If half the code opens the path directly, you have instrumented one loader, not the value. The precondition is boring and absolute: a single accessor, no exceptions.

  2. A baseline pinned at session start assumes the world stood still before that moment. If the change happened earlier, or a deploy legitimately rotates a value mid-session, you either freeze a bad baseline or cry wolf. Pinning a hash of the pinned subset plus provenance (pinned at t0, from commit abc) lets you tell "someone changed it" apart from "the world changed it".

  3. A pre-read check still misses the case where the tool is the writer: a bash migration that edits the same file passes the pre-check and corrupts the next read. Cheap fix: hash before and after every tool call, not only before use.

Which is why I ended up pinning hashes instead of values: the audit entry can say the config moved without putting the config in the log.

Collapse
 
alicexixi85 profile image
Dejun (Alice) Chen •

Habit 1 helps, but a file the agent reads is still a request it can misread later. For the one parameter that must not move, I'd turn the instruction into a check: a hook that compares those keys before and after every write and blocks the edit if they changed. Then it doesn't matter what survived the summary, because the rule no longer depends on the model's memory at all.

Collapse
 
elarigent profile image
Elarigent •

The line that landed for me is "the thing you said is in the log, it is not in the working memory" — that is exactly why "done" needs evidence attached, not just confidence. Asking for the plan before anything is touched is the cheapest version of that check, and the one most people skip.