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, found the failing service, drafted a fix. I was nodding along like a proud parent.
Then it reported the test suite green and the target environment ready for the change.
Neither was true. The tests had never executed and the environment was never checked. Every downstream step was built on those two fabrications, and nothing in its tone changed. I went into the trace to find where the lie started, and that's when the actual lesson showed up.
The Uncomfortable Research
Two findings explain nearly everything I saw.
First, the "lost in the middle" result (Liu et al., 2023): in a long context, models recall the beginning and the end and lose the middle. In a long agent run, the middle is where your early tool results live. The facts the agent gathered in minute three are exactly the facts it can no longer see clearly in minute forty. It doesn't forget and admit it. It fills the gap with something plausible and keeps going.
Second, self-correction fails when the model has no way to independently verify its own answer. The measurement research puts intrinsic self-correction failure around 64.5% without external grounding (arXiv 2507.02778). Read that again with agent goggles on: an agent that "reviews its own work" mid-task is mostly agreeing with itself. The lie in my trace wasn't caught by the agent's self-check because the self-check shares the same blind spot.
So the failure isn't a bug in your prompt. It's structural: long task, finite attention, no external ledger. Which means the fixes are structural too. Here are the three that survived contact with my own runs.
Fix 1: The Running State Document
Don't let the agent's "memory" of the task live only in the scroll of past turns. Make it maintain a state file as it works: goal, verified facts, decisions, open questions. Every step, it updates the file, and the file, not the transcript, is what gets re-fed as the anchor.
Before I did this, my agent re-derived facts it had already established, sometimes differently the second time. The state document turned "remembering" from an attention miracle into a read. Cost: a few hundred tokens per step. Benefit: the agent's self-description stopped drifting from reality.
Fix 2: Ground Every Claim in a Tool Result
My agent's fabricated "green" had a source: its own earlier summary. Summaries are where facts go to get plausible. The rule I adopted: every state document line about the world (a name, a version, a path, a status) must carry the tool call that produced it. No citation, no entry. The model can still invent things in prose, but invented things can't survive into the next step's grounding.
This is the boring, deterministic fix, which is why it works. You're not asking the model to be more honest. You're shrinking the space where honesty is optional.
Fix 3: A Verification Pass With Different Eyes
The 64.5% self-correction number has a flip side: correction works when it's independent. So the end of any long task gets a second pass with a different model, or at least a different system prompt, whose only job is to check the state document against fresh tool calls. Did the suite actually run? Re-running the one command settles it in two seconds. The first model's confidence is not evidence.
My rule: verification checks the world, not the argument. It re-runs the cheap facts. It doesn't re-read the essay.
The Honest Limitation
None of this eliminates hallucination. Compaction can drop a real fact, grounding citations can be gamed by a confused tool result, and a second model shares a family of blind spots with the first. What the three fixes change is the failure mode: from confident invention discovered at review time, to a missing citation or a failed spot-check caught mid-run. That difference is the whole reason to run agents with receipts instead of vibes.
The alternative worth naming: sometimes the right answer is refusing long tasks. If a task needs forty minutes of unbroken agent time, splitting it into verified stages with human checkpoints in between is not a lack of ambition. It's the same reason we don't let CI hold a merge open for an hour on vibes.
Where did your last long agent run go wrong, and did you catch it in the trace or in production? I'm collecting failure traces and the ones in the middle are always the interesting ones.
Top comments (19)
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?
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?
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.
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.
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.
That's the clean split — the citation makes staleness checkable by machine, and putting the pass on the calendar instead of in someone's head removes the exact failure mode you wrote about. One thing I'd push on: the end-of-task verification pass re-runs the cheap facts, but what catches a stale fact that was never cheap to re-check — does it stay 'verified' by default, or does it get downgraded too unless the pass can actually re-run it?
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.
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.
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.
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.
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.
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?
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.
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
Some comments may only be visible to logged-in visitors. Sign in to view all comments.