← Return to studyEsc

FROM THE BOOKSHELF / A PAGE TO KEEP

AI 洞察
45 分钟

Your Agent Writes 47% of Your Code. Who Checks the Tests It Wrote for Itself?

胡新宇

Published on 2026-08-28

JetBrains found agents fully generate 47% of professional developers' code. The tests come from the same agents. A look at mutation-checked verification gates, the VACUOUS vs UNVALIDATABLE split, and trust as a revocable state variable.

JetBrains asked more than 15,000 professional developers in May-July 2026 what happened to the code they shipped last month. On average, 47% of it was fully generated by agents. Over half of those developers now write less than 20% of their code by hand, and one in five writes no code at all without AI help (JetBrains Developer Ecosystem Survey 2026).

Generation scaled. Verification did not.

The suite that used to be your evidence is now written by the same thing it is supposed to be watching.

The test that could never have failed

On August 26, a freeCodeCamp tutorial walked through a failure that should be pinned above every CI dashboard. The author had shipped a fix for a hallucination bug — a rule telling the model not to fabricate one payment provider's docs under another provider's name — and signed it off in writing as HUMAN-VERIFIED, citing a real number: zero fabricated responses out of five. Clean run. Done.

Then he re-ran it at a fixed temperature with no fixed seed. The actual clean-decline rate was 66.7% (freeCodeCamp, "How to Stop Letting AI Agents Fake Their Own Tests", 2026-08-26).

He did not lie. He confused one clean run with verification, which is a different thing and a much cheaper one.

That same confusion has a much larger version inside your test suite. When you ask an agent for a fix, it hands you a test alongside it, because that is what agents do now. Nothing in your pipeline asks the only question that matters: would this test notice if the thing it guards broke?

Plenty of LLM-written tests would not. They call the function, get a list back, assert the result is a list, and pass. It looks like coverage. The green checkmark carries no information, because red was never reachable. And the failure compounds — that test keeps passing after the behaviour it was supposed to protect breaks for a second, unrelated reason. It looks exactly like every other passing test in the suite, which is the problem.

Mutation checking, applied at the criterion level

The tool in that tutorial, spec-verify, is a Claude Code skill, and its loop is worth stealing whether or not you ever install it. For each Given/When/Then acceptance criterion it does four things:

  1. Generates a concrete assertion on a return value, on state, or on a side effect — never "runs without throwing."
  2. Generates one targeted mutation, not a general mutation-testing sweep. The break is informed by the paired [ASSUMPTION: ...] tag from the spec, so if the spec named the risk, the mutation reintroduces exactly that risk.
  3. Runs the test against the mutant.
  4. Fails closed. A criterion whose test cannot be validated blocks "done" loudly, by name, with the reason stated.

Step three is the whole product. A test that still passes after you deliberately reintroduce the bug it was written for never checked anything. spec-verify calls that VACUOUS and refuses to trust it. The published proof run shows two tests generated from the same criterion — one flips to failing under mutation, the other passes both ways. Same green checkmark before you looked. Completely different amount of protection.

Targeting matters more than volume here. Classic mutation testing sprays hundreds of mutants across a file and hands you a score you learn to ignore. One mutation derived from the assumption the spec already flagged as risky is a question with a yes-or-no answer.

A test the agent wrote for its own code is a student grading their own exam with an answer key they invented. Mutation checking is the proctor who quietly changes one question and watches whether the grade moves.

Two failure modes that look identical and are opposites

The second idea in that piece is the one most teams will get wrong.

Not every criterion can be mutation-tested. The entity-grounding rule in the story lived entirely in a system prompt — plain-language instructions to a model, no function boundary to call, nothing to assert on. The only way to check it is to ask trick questions and read the answers. spec-verify labels that UNVALIDATABLE.

Treating UNVALIDATABLE like VACUOUS breaks the gate in one of two directions. Either you start waving vacuous tests through because "some things just can't be tested" — they can, that one simply was not written to — or you block forever on anything non-deterministic, which on a real codebase is most of the interesting behaviour.

So the gate runs two tracks. VACUOUS and BROKEN-TEST get no waiver, ever; the only way past a defective test is a better test. UNVALIDATABLE clears through an explicit, on-record human sign-off in which a person states in writing how they actually checked it.

And here the author turns the knife on himself, which is why the piece is worth reading. His own sign-off passed the structural check. It was not empty, it was not a one-word rubber stamp, and it named an actual method. The structural check rejects blank notes, sub-sentence notes, and a blocklist of stock phrases like "looks fine" and "lgtm" — and it cannot verify that a human did what they claim. It raises the price of the laziest rubber stamp. That is all it does.

The honest fix was not a better sign-off. It was replacing the thing being signed off: a deterministic code-level gate for the known problem cases, testable the normal way, sitting next to the prompt-based check for everything else. UNVALIDATABLE is a flag that something needs a human, or better, needs to stop needing one.

Trust as a state variable, not a provisioning decision

The same week, AWS published the infrastructure-shaped version of this argument. Identity and access management answers "who can do what" once, at provisioning, and assumes the principal behaves consistently. An LLM agent breaks that assumption cleanly: the same agent can be accurate on Monday and hallucinating on Tuesday after a prompt edit or a model update. Most teams respond with a binary — full access or read-only. Full access is dangerous because agents fail unpredictably; read-only leaves most of the agent's value on the floor (AWS Architecture Blog, "Closing the AI agent trust gap with graduated autonomy", 2026-08-26).

Their pattern, graduated autonomy, makes permissions a function of recent behaviour across six layers: a scoring engine, a tier system running T1 through T4, pre-execution filters, Cedar-policy enforcement outside the agent's own process, post-execution evaluation that records decision provenance, and a delivery gate that keeps degraded agent versions out of production.

Two of their design decisions transfer directly to your test gate. Safety is an independent floor, never averaged away by strong metrics elsewhere — the same reason a vacuous test cannot be offset by 400 good ones. And every agent starts at T1: promote slowly, demote immediately. Asymmetric, deliberately.

Why the tooling is arriving now

Evaluation has been the awkward part of this stack because most evaluation systems assume one SDK, one LLM client, one tracing pattern, and break the moment you step outside that zone. AWS's AgentCore Evaluations, also shipped that week, decouples scoring from framework choice by reading OpenTelemetry traces: LangGraph, LlamaIndex, the OpenAI Agents SDK, Google ADK, the Claude Agent SDK and Strands all score through the same pipe (AWS ML Blog, 2026-08-26).

Read those three releases together and the shape is clear. Verification is becoming a layer with its own primitives — mutation-checked criteria, trust tiers, framework-neutral traces — rather than a habit you rely on individual engineers to maintain.

One thing nobody has measured yet: what share of agent-written tests in a live codebase are vacuous. The spec-verify proof is a two-case demonstration, not a survey. Anyone quoting you a percentage is guessing.

Three changes worth making this week

  • Take one recently-merged agent-written test and break the code it covers on purpose. Not a rewrite — reintroduce the specific bug the test was created for. If it still passes, you have found your first vacuous test, and you now know the rate is not zero.
  • Split your "can't test this" bucket in two. Defective tests and non-deterministic criteria need opposite treatment: one gets a better test with no waiver available, the other gets a named human and a written method. A single bucket guarantees you handle at least one of them wrong.
  • Make one permission revocable. Pick the riskiest action your agent can take today and attach it to a recent-behaviour signal instead of a provisioning decision. Promote slowly, demote immediately.

Every one of those 47% of agent-written lines arrived with a test attached. The question is not whether you trust your agent. It is whether the green check in front of you was ever capable of turning red.

#AI Agent#AI工程#AI编程#代码治理