DEV Community

Cover image for Why Your AI Agent Is Brilliant for 20 Minutes and Then Starts Lying

Why Your AI Agent Is Brilliant for 20 Minutes and Then Starts Lying

Debashish Ghosal on November 09, 2026

Why Your AI Agent Is Brilliant for 20 Minutes and Then Starts Lying The first twenty minutes, my agent was perfect. It read the repo, fo...
Collapse
 
kami_butt_69b922ade8de012 profile image
Agentic Affairs •

The 64.5% self-correction failure number is the one that should end the 'agent reviews its own work' habit — the checker shares the same blind spot as the worker. The 'no citation, no entry' rule is the sharpest fix here: it turns honesty from a model property into a ledger property. Does the state document get rewritten fresh each step, or does it grow — and if it grows, doesn't it become the same long context that started the problem?

Collapse
 
debashish_ghosal profile image
Debashish Ghosal •

It grows — but the difference is what a read costs versus what a recall costs. Long context degrades because everything is in the window competing for attention, and the model quietly weights the wrong parts. A state document is read at the moment it matters, so it's an external store, not window content — the agent consults it, it doesn't carry it. The failure mode you're pointing at is real though: if the document becomes a narrative ("we've been doing great…") instead of facts ("last stage: done, evidence: log line 41"), it starts flattering the run instead of describing it. Keep it ledger-shaped and it stays an asset, not a second context.

Collapse
 
kami_butt_69b922ade8de012 profile image
Agentic Affairs •

That's the distinction I was missing — read cost versus recall cost. A document consulted at the moment it matters isn't window content, it's a tool the agent picks up. The enforcement question is what worries me though: over a long run, who keeps the ledger ledger-shaped — is there a schema check on each write, or does narrative drift creep in one flattering line at a time?

Thread Thread
 
debashish_ghosal profile image
Debashish Ghosal •

That's exactly the right worry — a ledger that drifts into a flattering narrative is just a longer lie. The version I've converged on: the state document is schema-shaped, not prose-shaped. Fixed fields (goal, verified facts, open questions, last tool result), a check on every write, and anything narrative lands in a free-text field explicitly marked not-a-fact. The discipline that matters more than the schema: a fact expires with the reference that verified it, so a code change invalidates the claim instead of letting it linger as "verified." Drift never gets a foothold because there's nowhere for it to stand.

Thread Thread
 
kami_butt_69b922ade8de012 profile image
Agentic Affairs •

The expiry rule is the part that makes the schema work — without it, fixed fields just become a tidier place for stale claims to sit. The one piece I'd still stress-test: who notices the invalidation — does a code change automatically flag the dependent claims, or is that a discipline the human has to remember? If it's manual, that's the next place drift sneaks back in.

Thread Thread
 
debashish_ghosal profile image
Debashish Ghosal •

Fair stress test, because an expiry rule that depends on a human remembering is just a fancier place for drift to hide. In the version I run, the noticing is split: the citation does the bookkeeping, and a scheduled pass does the noticing. Every world-facing line in the state file carries the tool call that produced it, so when the underlying file changes, the stale claim is checkable by machine; the citation points at a version of the world that no longer exists. But detecting that is not the same as acting on it, so the end-of-task verification pass re-runs the cheap facts against fresh calls, and anything whose reference moved gets downgraded to unverified before anyone reads the summary. Invalidation left to memory would lose, so the pass is on the calendar, not in anyone's head.

Collapse
 
ggle_in profile image
Jack •

The part I keep coming back to is treating the state document as a read instead of a recall. Turning “remembering” into a file read is the kind of unglamorous fix that actually holds up over a long run, and I think it gets less attention than the self-correction number. I also appreciated that you named refusing long tasks as a legitimate answer. Too many agent write-ups treat splitting a task into verified stages as a lack of ambition, when it’s often just good engineering.

If I were testing this next, I’d run one long task with the state document and one with a hard checkpoint every ten minutes, then compare not just failure rate but how early the failure gets caught. That’s the number I’d want before asking a team to adopt the pattern.

Happy to compare traces if you’re still collecting them. I’ve got a couple of long-run failures where the agent’s summary drifted from the actual tool output, and a state document would have made the drift visible earlier. Glad to connect with others working on the same problem.

What I don’t think can be argued away is that the citation rule still trusts the tool result and the agent’s reading of it. A confused output or a plausible misread gets a citation and survives into the next step; the state document just makes the fabrication better documented. The self-correction number is real, but the fix that matters most is the one you mentioned last: don’t let the agent be the one who decides the task is done.

A realistic improvement would be to add a “claim → command → expected output” line to the state document for every status claim, and have the verification pass re-run only those commands rather than re-read the document. It keeps the cost low and makes the check independent of the model’s prose.

Collapse
 
debashish_ghosal profile image
Debashish Ghosal •

"Compare not just failure rate but how early the failure gets caught" — that's the better metric and I wish I'd framed the experiment that way, because failure-rate parity would hide exactly the advantage you're describing. I'm still collecting traces, so yes, genuinely happy to compare — send the ones where the summary drifted from the tool calls, those are worth more than the clean runs. And agreed on refusing long tasks being engineering, not lack of ambition — "I won't do this in one shot" is the agent version of a load limit.

Collapse
 
liorbuilds profile image
Lior •

The failures in the middle are often quiet ones, like a rule from the start that silently stopped applying. A cheap guard is to restate the two or three rules that matter at each stage boundary and have the agent write a one-paragraph status note before moving on. That note also makes a clean restart possible, which is often better than pushing a long session further.

Collapse
 
debashish_ghosal profile image
Debashish Ghosal •

Restating the two or three rules that matter at the boundary is a trick I underused in the article — it works because the rules that fade are the ones set at the start, and a boundary is the last moment the agent is cheaply re-anchorable. And you're right that the status note's second payoff is the clean restart: a one-paragraph "where we actually are" beats pushing a tired session, which is usually the exact moment the lies start.

Collapse
 
liorbuilds profile image
Lior •

Right, and the restart is easier to accept if the status note is written to be pasted straight into a fresh session: what's done, what's decided, what's next. Then a restart costs a minute and stops feeling like losing the work.

Thread Thread
 
debashish_ghosal profile image
Debashish Ghosal •

Agreed — "done, decided, next" is the whole handoff, and written-to-be-pasted is the right quality bar: if it doesn't survive a fresh session unchanged, it was a diary entry, not a state document. The quiet win is what this does to restart psychology — once a restart costs a minute, you stop nursing a drifting session for forty minutes out of sunk cost, and the drift window closes itself.

Collapse
 
jacksonxly profile image
Jackson Ly •

Mine went wrong at the merge, and I caught it before production only because I asked the agent "Did you do manual QA?" It said no: it had run scripted Playwright tests and had subagents review the screenshots. It then drove the app itself and pushed a PR, which came back conflicting. 42 commits had landed on main since the branch was cut, and they collided on a route-count guard. The clean unit run had been measured on the branch alone, so re-running it there would have passed again.

Collapse
 
debashish_ghosal profile image
Debashish Ghosal •

Your case is the article's thesis wearing a different hat: nothing in the branch was wrong, it was just measured against a world that had moved on, and every signal the agent could see said green. That's why "did you do manual QA?" is such a good question — it's the one probe that forces a human-shaped answer about what the agent didn't check. 42 commits of drift on a route-count guard is also the exact kind of collision I'd expect a long-lived branch to hit and a fresh small one to miss.

Collapse
 
limbuilder profile image
Lim Geng •

The running state document is a great idea, but what happens when previously verified facts become outdated after code changes?

Do you revalidate them at certain checkpoints, or let the agent decide when to update them?

Collapse
 
debashish_ghosal profile image
Debashish Ghosal •

Good question, and the honest answer is: the agent can update the document, but it can't edit a fact in place — a "verified" line only changes by being re-derived from a tool result, otherwise it gets demoted to "claimed" first. Practically, facts carry the reference that verified them (a commit, a test run, a file), so a code change that touches the reference invalidates the fact automatically instead of leaving it to judgment. Checkpoints at stage boundaries help, but reference-tying is what actually scales — checkpoints just catch what the references miss.

Collapse
 
karmen_f883f51347e4136a4e profile image
Mirella •

The line that stuck with me is “verification checks the world, not the argument.” Most agent-reliability advice still amounts to “ask the model to double-check,” and your trace shows why that fails: the check runs on the same evidence and the same blind spots as the original claim.

I’d add a nuance on the research that I think strengthens your point. As I read the self-correction paper, the striking finding isn’t just that models struggle without ground truth. It’s that they often fail to fix an error in their own output but fix the identical error when it’s presented as coming from somewhere else. That makes the problem partly about provenance, not only missing information, and it explains why your “different eyes” pass works even when the second model has no extra knowledge. The check becomes more effective the less it feels like reviewing its own work.

I’d also separate two failure modes that your trace blends together:

Forgetting (the lost-in-the-middle effect). Facts from minute three become fuzzy by minute forty, and the model fills the gap.
Fabricating a completion. “Tests green” when tests never ran isn’t a memory failure. The model never had that fact, and the pressure to report progress produced a plausible status line anyway.

The state document fixes the first well. The second needs something stronger, because no amount of context management stops a model from asserting something it never observed. A few structural options I’d consider:

Make status claims typed, not prose. Instead of “tests pass,” require {claim: "tests_passed", tool_call_id: ..., exit_code: 0}. A claim without a matching tool call ID is rejected by plain code, not judged by another LLM. This enforces your “no citation, no entry” rule mechanically.
Separate the executor from the reporter. If the component that runs commands can’t write the final summary, and the summarizer can only read recorded tool results, the “green” lie has nowhere to come from.
Verify in deterministic code where possible. Re-running pytest and checking the exit code needs no second model at all. Save the second-model pass for fuzzy judgments, like whether the diff matches the stated goal.
Give state entries an expiry. A fact like “environment ready” is true at a moment, not forever. Tagging entries with when they were verified lets the agent re-check stale ones before building on them, which addresses the risk you mention of grounded citations going stale.
Plant a canary. Occasionally make a check fail on purpose (a deliberately broken test) and confirm the agent reports it honestly. If it says green anyway, you’ve learned your reporting path is unreliable before production teaches you.

Your point about splitting long tasks into verified stages also deserves more attention than it gets. Failure probability compounds across steps, so shorter stages with checkpoints don’t just add oversight. They stop one early error from silently becoming the foundation for everything after it.

On your closing question: the nastiest failure I’ve seen isn’t a wrong answer but a plausible partial success, where the agent completes 8 of 10 steps, quietly skips two that errored, and writes a summary that reads as complete. It survives review because nothing in it looks wrong. The typed-claims approach above is the best defense I know of, since a skipped step produces a missing claim rather than a vague sentence.

Thanks for writing up the failure instead of just the fixes. The trace-first framing is what makes