Your Coding Agent Needs an Answer Key

To verify AI-generated code, give the agent an answer key it did not write: end-to-end tests that drive the real app in a real browser, run in CI, and are read back by the agent.

Cover Image for Your Coding Agent Needs an Answer Key

To verify code written by a coding agent, check it against tests the agent did not write, in a real browser, on a real build. Then have the agent read those results back and keep working until they are honest and green.

Coding agents now write much of the code. Writing it is no longer the slow part. Knowing it works is.

Why can't a coding agent grade its own work?

Because the agent that writes the code also writes the test, and both come from the same assumptions. If the agent misreads the requirement, the code and the test share the same mistake, and the test passes.

Self-grading fails in a few familiar ways:

  • It tests against its own mocks. The agent stubs the API, the database, or the login, then proves the code works against the stub. The real service never gets a vote.
  • It relaxes the assertion until it passes. A test fails on an exact value, so the agent loosens the check to "something is visible". The suite goes green and now covers less than before.
  • It reports green when the tests never ran. A setup step failed, a filter matched nothing, or a shard crashed. No test failed, because no test started. "No failures" reads as "all good".
  • It says "done" without opening the app. The code compiles and the unit tests pass. Nobody clicked the button.

None of this is dishonest. The agent is optimizing for a finished task, and a green check is the quickest way to look finished.

What counts as an answer key?

An answer key is a set of expected results that the author of the answers did not write. A teacher grades against it. The student cannot edit it.

For code, that means three properties:

  1. It is independent. The expectations come from the product's behavior, not from the implementation the agent just wrote.
  2. It runs the real thing. A real browser loads the real app and clicks through a real flow. Nothing in the path is a stub the agent controls.
  3. It runs where the agent cannot nudge it. CI runs it on every change, and the result is a record, not a claim.

End-to-end tests fit this well. They describe what a user does and what the user should see. That stays true however the code underneath changes.

How does an agent drive a real browser?

An external coding agent can drive a live browser one step at a time through the Donobu CLI. It starts a session, looks at the page, clicks, types, and checks what happened.

npx donobu session start

Each step is a small command with a structured answer. The agent sees what is on the page, acts, and sees the result. It does not guess from the source code what the screen probably shows.

When the flow works, the session saves a @donobu/test spec. That spec is native Playwright, and it replays without an LLM. The next run does not depend on a model's mood. It is a plain test file that your team owns and can read, edit, and keep in your repository. There is no proprietary format and no lock-in.

Donobu also ships an agent skill file, so coding agents learn these commands without extra prompting.

How does the agent read the results?

It reads the same results a person sees. With a Donobu API key, two commands cover it: one lists recent runs, and one opens a single run.

# list the 20 most recent runs, counted by test
npx donobu runs list -n 20

# open one run: latest, a run ID, an ID prefix, or a pasted CI run URL
npx donobu runs show latest

runs list prints one row per run, with columns for passed, failed, skipped, and not run, plus the CI run and the branch. runs show names each failed test and the result that holds it. Both take --json, so an agent can parse the output.

This closes the loop. The agent pushes a change, CI runs the suite, and the agent reads the verdict instead of assuming one. A red run is now a task, not a surprise.

Terminal output of npx donobu runs list, with a NOT RUN count per run

What about tests that never ran?

A test that never started leaves no failure behind, so a run can look green while checking less than it should. This is the quiet failure mode of agent-driven work, because an agent that sees no red will stop.

Donobu records which tests each run expected. Tests the run never started are counted as NOT RUN, next to passed, failed, and skipped. Each test counts once, by its final verdict.

So the agent sees "3 not run", not a clean zero. A failed setup project, a cancelled job, or a --max-failures stop no longer hides behind a green badge. For the full story, read The Tests Your Green Run Never Ran.

NOT RUN is known on Donobu Cloud, where the expected tests are recorded. Local runs list passed, failed, and skipped only.

Where does a person stay in the loop?

A person reviews every change that touches a test. An answer key only works if the student cannot quietly rewrite it.

When a test fails, Donobu's auto-heal proposes a fix as a pull request. A person reviews that pull request, as with any other code. Heal also flags fixes that weaken a test, such as a check replaced by a looser one, so a reviewer sees the loss of coverage and not just a green result. The details are in Failing tests now arrive as a pull request.

This is how Donobu works in general. AI agents run the regression tests. SDETs review every result. Everything runs local-first or in your own environment, and the tests stay yours. AI runs the tests. We own the quality.

The short version

An agent that grades its own work will tell you it is done. An agent that is graded by tests it cannot edit will tell you what is true.

Give your coding agent a real browser to drive, a suite it did not write, a CI run it cannot skip, and a command to read the verdict. Keep a person on the review.

To set up the loop, start in the Donobu docs.