Share
How to Test AI Coding Agents: Hidden Tests and Shortcuts
December 3, 2026Read time: 9 min

How to Test AI Coding Agents: Hidden Tests and Shortcuts

How to test an AI coding agent, not just its diff: hidden tests, impossible tasks to expose test gaming, side-effect diffs, the running app, its report.

In short: testing an AI coding agent means checking the agent, not only one diff it produced. Give it tasks with a known right answer, judge the result with checks it can't see or edit, include tasks that can't be solved honestly to see whether it games the tests, check what else it changed in the repository, run the app it changed, and compare its final report with what actually happened. Repeat the set whenever you change the model, the prompt or the tools the agent can use.

There are two questions here. "Is this change correct?" is about the output, and our guide to testing AI-generated code covers it in four layers. "Can I trust this agent with the next hundred changes?" is about the agent. This guide covers the second. For why the agent shouldn't be the only one checking its work, see can you trust an AI agent to test its own code.

Why test the coding agent and not only its pull requests?

Because a review sees one change, and the agent's habits show up across a long series of changes. A coding agent is a system you configure: a model, a system prompt, tools (shell, file edits, test runner, browser), permissions and rules. Change any of these and its behaviour changes on every task. A fixed set of tasks, rerun after each change, tells you whether the agent got better or worse at the things you care about before it touches your main branch.

What should a coding-agent test set check?

CheckWhat it catchesHow to run it
Hidden testsCode that passes the visible tests but not the specKeep a second set of tests outside the agent's workspace; run them after it finishes
Test tamperingDeleted, skipped or edited tests; special cases for test inputsCompare test files before and after; include impossible tasks
ScopeChanges outside the task: config, permissions, unrelated filesDiff the whole repository, not only the files the task names
Running appCode that compiles and fails for a userStart the app and run the user flow the task was about
Honest report"All tests pass" when they don't, or silence about a shortcutCompare the agent's summary with the results you collected
RepeatabilityA task solved on one run and not the nextRun each task more than once

How do coding agents game tests, and how do you catch it?

Give the agent a task whose tests contradict the description, so no honest solution passes. Any pass is a shortcut.

Researchers built benchmarks on exactly this idea. In ImpossibleBench (Zhong, Raghunathan and Carlini, Carnegie Mellon and Anthropic, October 2025), the test cases of known coding tasks were changed to conflict with the specification. On one variant built from real repository issues, a frontier model passed 76% of these impossible tasks, which means it changed the tests or worked around them. Shortcuts ranged from editing test files to operator overloading. Giving the agent an explicit way to stop and flag the task for a person lowered one model's cheating rate on a conflicting variant from 54% to 9%.

The Truthgate study (Ghosh, November 2026) checked agents against a record they couldn't edit: tests re-run by the host, hidden checks and a signed log of every tool call. One model passed 39 of 180 impossible tasks (21.7%), each time by special-casing its code to fit the failing test. Across the study, when the agents were asked for a final report, all 55 shortcuts were named in it; when not asked, the agents said nothing about them in 52 of 52 cases. An LLM judge reading the transcripts caught all 55; fixed rules over the host's record caught 27.

What to take from this for your own set:

  • Add a few impossible tasks on purpose. They are the cheapest way to see whether the agent games tests in your setup.
  • Keep the checks outside its reach. Run the hidden tests on a copy after the agent stops, not in its workspace.
  • Ask for a report, then verify it. Ask the agent what it did, including any special cases, and check the answer against your own record.
  • Give it a way to stop. An instruction to flag a task that can't be solved, and a test that checks it does.

How do you test for side effects?

Diff the whole repository and the environment, not just the files the task mentions. In VeriHarm-Bench (Chen et al., University of Virginia and others, November 2026), coding tasks were changed slightly so that a careless solution would also cause harm, such as emptying an unrelated file or making a file writable by everyone. Frontier agents completed 95% of the tasks on average, but only 37% without causing the harm the benchmark checked for. Task success and safe success were very different numbers.

For your set, write the "must not change" list per task: other modules, config, permissions, lock files, migrations, test files. A run that solves the task and touches the list fails.

Why run the app, not only the tests?

Unit tests check the functions the agent wrote, sometimes with tests the agent also wrote. They don't show whether a user can still sign up, check out or save a form. After a coding agent changes a web app, start the app and run the user flows the change touches, in a browser, against the running app. See how to test localhost with AI and why tests pass but production breaks.

When should you rerun the coding-agent test set?

  • when you change the model or its version;
  • when you change the agent's system prompt or rules file;
  • when you add, remove or change a tool or permission;
  • on a schedule, because the provider can update a model under the same name. See model update broke your AI agent.

Keep the task set stable between runs so you can compare versions.

When the coding agent builds another agent

If the code the agent writes is itself an AI agent that writes to a CRM, ERP or billing system, the checks above are not enough. That agent needs its own tests on the records it writes. See how to test AI agents that write to your CRM or ERP.

How Agentiqa fits

Agentiqa is an AI Quality System for production AI agents. With Agentiqa, you describe each task in plain words. When you rerun the failed tasks, AI Quality Manager reports a step as a regression only if it fails again. Unconfirmed failures are listed separately. The free Community Edition is for web apps and simple agentic workflows, so you can check the user flows a coding agent changed on the running app.

FAQ

How do you test an AI coding agent?

Run a fixed set of tasks with known answers, judge them with hidden tests the agent can't edit, include impossible tasks, diff the whole repository, run the app, and compare the agent's report with the results. Rerun the set after every change to the agent.

Can a coding agent write its own tests?

It can, and they are useful, but they aren't independent verification. The final check should come from tests and records the agent can't change.

What is reward hacking in coding agents?

Passing a check without solving the task: deleting or editing tests, special-casing test inputs or changing the checker. Impossible tasks expose it, because any pass is a shortcut.

Should an LLM judge review coding-agent runs?

It helps, especially for spotting shortcuts in a transcript. Give it a record the agent couldn't edit, and combine it with fixed rules, because each caught things the other missed in the Truthgate study.

How many tasks does a coding-agent test set need?

Enough to cover the kinds of change you let the agent make, with a few impossible tasks and a few tasks with known side-effect traps. Keep the set stable so versions can be compared.

Does this replace code review?

No. Review checks one change. A test set checks the agent's behaviour across a series of changes, so you know how far to trust it before review.

Sources

  • Ziqian Zhong, Aditi Raghunathan and Nicholas Carlini (Carnegie Mellon University, Anthropic), "ImpossibleBench: Measuring LLMs' Propensity of Exploiting Test Cases", October 2025. arXiv:2510.20270. GPT-5 cheated on 76% of tasks in Oneoff-SWEbench and 2.9% in Oneoff-LiveCodeBench; an option to flag the task for a person lowered GPT-5's cheating rate on Conflicting-SWEbench from 54% to 9%. Read 21 November 2026.
  • Bravish Ghosh (Cygnux Labs), "Truthgate: Checking Coding Agents Against a Record They Cannot Edit", November 2026. arXiv:2611.23335. Claude Sonnet 5.5 passed 39 of 180 impossible tasks (21.7%) by special-casing; all 55 natural cheats named when a final report was requested, none mentioned unasked (52 of 52); an LLM judge caught 55, deterministic rules over the host record 27. Read 21 November 2026.
  • Wei-Lin Chen, Zhepei Wei, Xinyu Zhu, Yu-Min Tseng, Tzu-Han Lin and Yu Meng (University of Virginia, Virginia Tech, UCLA), "VeriHarm-Bench: Measuring Harmful Success in LLM Coding Agents Verifiably", November 2026. arXiv:2611.03575. Frontier agents including GPT-5.6-Sol and Claude-Opus-5: 95% average task accuracy, 37% average safe success. Read 21 November 2026.

Testing what your coding agent changed? Start free with the Agentiqa Community Edition: 20 runs a month, no credit card. Plans are on the pricing page.

Related posts