Egor Urvanov

What are quality gates for AI agentsCheckpoints that raise quality and autonomous run time

A quality gate for an AI agent is an external control point: the work stops until an independent check answers “accepted”, and the agent never marks “done” itself. The gate stands outside the agent and outside its bounded context, behind MCP or another separator. It raises quality and lengthens autonomous work. Below: kinds, numbers, MCP and limits.

The author’s thoughts. The idea that a gate is an external part and stands behind the agent’s context border, and the conclusions from it, belong to the author: a gate belongs at a bounded-context border; one narrow set of MCP functions both saves context and limits permissions; gates lengthen autonomous work. No source words it as “a gate behind the context border”. Nobody has measured the lengthening of autonomous work: the autonomy section offers a calculation and cases, not a sample-based experiment. Sources confirm separate links, and next to them stand an address and the exact phrase.

In short: what a gate is and why an agent needs one

The gate is in another context, behind a narrow neckthe agent’s contextanother contexteverything else is forbiddenMCPthe gateaccepteda person decides● model, people, systems, data  ● agent and harness  ● risk, stop, boundary

The road of the work: the agent walks through its own context step by step, the work reaches, through MCP, a gate that stands in another context. The gate answers “accepted”, “back with an error” or “not sure, a person decides”.

What it is. A gate stands between the agent’s work and the word “done”. The agent brings a result, and the check gives one of three answers: accepted, not accepted (errors go back to the agent) or not sure (a person decides). The post says “done”. If the check fails, the work goes no further: not to the next step, not into a merge, not to the user. A gate is an external part: a control point cannot stand in the same bounded context as the agent, or it shares the agent’s blind spots. So it stands behind a separator: behind an MCP server, in a client hook or in another process. Very little crosses this border in either direction: a short result there, a short answer back, everything else is closed. A gate works because checking is usually easier than doing. This is kin to the “P versus NP” question of complexity theory: finding a solution may be hard, checking a finished one is fast. For agents this is only an analogy: a check is not cheap for every task, and where it is not, the gate leans on a person.

Why. The first reason is quality: an agent grades its own work poorly, and an independent check sees what it missed. The second is autonomy: an error caught at a step does not travel through the next twenty steps, so the agent can work longer without a person. The third is a person’s attention: they look only at the disputed cases the gate handed over.

Where to put it. Outside the agent and outside its context: in a client hook or in server permissions behind MCP, and not in instruction text the agent may ignore. The agent itself works inside a small bounded context: there a check is finite, the change is small and the set of MCP functions is narrow. These places are covered in the “Border” and “MCP” sections.

Takeaway
In this exampleThe agent finished editing the booking form. Without a gate it writes “done”. With a gate, tests and the booking-rules check run: if a test fails, the agent gets the error text and continues, and a person hears about the change only when everything passed or when the check said “not sure”.
In generalA gate takes away the agent’s right to mark “done” itself and hands it to a check that stands outside the agent.
Next stepPick one task the agent does regularly and write the “done” condition as one checkable sentence: “all tests are green and the linter is silent”.

Where the word comes from: from code inspection to gates for agents

The word “gate” came from product management, factories and software engineering. Below are four points on the way, and each carries an idea that agent gates inherited.

1976Code inspectiona review before handover1990Stage-GateCooper: go or kill at every stage2020Gate on new codeSonar: pass or fail, nothing between2026Gates for agentsSonar, Anthropic, Radar● model, people, systems, data  ● agent and harness

Code inspection, Stage-Gate, a gate on new code, and gates for agents.

1976: code inspectionFagan introduced formal code inspection before handover. A 2026 survey calls review the “primary quality gate” ever since.
1990: Stage-GateRobert Cooper described a project as a chain of stages with gates between them that decide “go on or stop”. His institute’s site puts it this way: gatekeepers make such decisions on time.
2020: a gate on new codeSonar defined a gate as a binary decision: pass or fail. It looks at code added or changed recently; the whole history is outside the check.
2026: gates for agentsThoughtworks Radar calls compilers, linters and tests deterministic quality gates and advises wiring them into agent workflows. Sonar has a separate set of conditions for code written by agents.

Two more ideas came from factories. Deming’s third of fourteen points says to stop depending on inspection at the end and to build quality into the product from the start. In its jidoka system Toyota makes equipment stop at once when it detects an abnormality. An agent gate joins both ideas: the check stands as early as possible and can stop the work.

Takeaway
In this exampleFagan checked code with people, Cooper put gates between project stages, Sonar made a gate automatic, and for agents a gate became the point where work does not go on without a verdict.
In generalAn agent gate is not a new invention: it is an old control point moved to where a machine does the work, and the machine checks itself poorly.
Next stepLook at which gates your project already has for people: tests in CI, mandatory review, a linter. The agent should pass the same ones.

Why an agent does not check itself

The first thing research shows: an agent overrates its own work. Anthropic found that separating the agent doing the work from the agent judging it is a strong lever. They also note that out of the box Claude is a poor reviewer and had to be tuned for strictness.

The most detailed measurement is a preprint by Park and Choi (July 2026, a draft pilot). The same agent ran six improvement cycles, and only whoever closes the feedback loop changed, that is, the judge of the result: the agent itself, a strong judge inside the loop, or an external check that sees the real outcome. The chart shows the final score of each variant.

Final score after 6 improvement cycles (higher is better)Start33.3The agent grades itself76.7A strong judge inside the loop86.7A check from outside113.0peak 95.0 → 19% rollbackPilot: one model, one task, three repeats. The agent called all 54 cycles an improvement, yet 56% had zero or negative change● model, people, systems, data  ● agent and harness  ● risk, stop, boundary

The agent’s self-grading rolled back what had been achieved by 19%, and the external check gave the maximum. A pilot: one model, one task, three repeats.

What stands behind the numbers. The agent called all 54 cycles an improvement, although in 56% of them the real change was zero or negative: self-grading turned into “accept everything”. Even the strong judge inside the loop accepted real regressions in 44% of cases and rejected 38% of real improvements. The authors explain the gap this way: the gap is set by what the judge relies on, and the judge’s intelligence does not affect it. A judge inside the loop sees only what the agent showed it. An external check looks at the real outcome.

Anthropic reached the same conclusion with its C compiler (a case described by Anthropic itself): 16 agents, about 2,000 sessions and about $20,000. The author named a nearly perfect verifier as the main condition. The same article warns. Tests pass and the work is not done: this happens while a check is not deterministic. A deterministic check on the same data always gives the same verdict, like running tests or a linter. A judge model’s answer may differ from run to run, so the judge adds to the check program and does not replace it.

One more observation from the pilot: one bit was enough for the external check. A verdict “accepted” or “rejected” without any explanation scored 110.0 against 113.0 with a full write-up. So a gate does not have to give its reason: a yes or a no is enough.

Takeaway
In this exampleThe agent in the loop called everything an improvement, and the external check, looking at the real result, cut off regressions.
In generalA check inside the agent’s dialogue inherits its blind spots. What makes a check independent is reliance on an outside fact: a test run, a real result, a separate reviewer with access to the real product.
Next stepReview your prompts to the agent: if they contain “make sure everything is right”, replace it with a check run whose result the agent cannot write itself.

Three kinds of check at a gate

An intake post can hold a check of three kinds. They differ in speed, price and what they can see, so in practice several are placed in a row: a cheap fast one first, a pricey rare one last.

npm testA machinetests, types, linterA reviewing agenta threshold per criterionA personmeaning and riskseconds, cheaphours, expensive● model, people, systems, data  ● agent and harness

Left to right the check gets smarter, slower and pricier.

KindWhat it seesExampleWeak spot
A machineanything written as a rule: tests, types, linter, build, coverageSonar for agents: new-code coverage at least 80%, duplication at most 3%, no new bugs or vulnerabilitiessees no meaning: sensors catch misdiagnosis, needless complexity and misread tasks unreliably
A reviewing agentmeaning by criteria with a thresholdAnthropic: below the threshold on any criterion, the stage fails; Spotify’s judge vetoes about a quarter of sessionspricier, needs tuning for strictness, and it errs too
A personrisk, intent, consequencesGitHub: draft PRs from the agent are approved and merged only by a humangets tired and used to approving

A machine. Sets the lower level. For code written by agents Sonar requires six conditions: no new bugs, vulnerabilities or maintainability issues above a threshold, new-code coverage of at least 80%, duplication of at most 3%, and no new dependency risks. The last condition appeared because of agent behaviour: they may install packages without vetting. For the split of checks into guides and sensors see the article “Harness engineering in practice”: a gate is a sensor that has the right to stop the work.

A reviewing agent. At Anthropic each criterion had a hard threshold, and if even one fell below it, the stage failed and the agent received a detailed write-up. Before a stage the executor and the reviewer agreed a stage contract: what counts as “done”. Spotify added a judge after agents began doing extra: refactoring code outside the task and disabling flaky tests. The judge compares the change with the original request.

A person. GitHub built the human into the process itself: the agent can neither mark its PR ready, nor approve it, nor merge it. Such a gate is needed where an error is costly: money, access, other people’s data.

A gate has three answers: accepted, not accepted and “not sure”. The third hands the case to a person and shows where the check’s frame ended. Why such an answer is unavoidable for any agent code is covered in the article “Where to check an AI agent’s work”.

Takeaway
In this exampleTests passed in 40 seconds. The reviewing agent found that the button works but looks different from the task. The person got only this disputed case.
In generalFast gates stand before costly ones: the machine filters the obvious, the agent judges meaning, the person decides risk.
Next stepList your project’s checks across the three rows of the table. An empty row means that kind of gate is missing.

What gates give quality, and what it costs

The numbers below come from four separate sources: two Anthropic write-ups (24 Mar 2026 and 5 Feb 2026), engineering blogs of Stripe and Spotify, and the DORA 2025 report. No sample-based studies exist: nobody has published “with a gate and without” comparisons over hundreds of tasks, so each number serves as an example. The link next to each number shows where it comes from.

A single agentAgent and reviewer20 minutes · $9the main feature did not work6 hours · $200it works, noticeably higher qualityOver 20× the cost. One case, no statistics (Anthropic, 24 Mar 2026)● model, people, systems, data  ● agent and harness  ● risk, stop, boundary

One request: an agent alone and an agent with a reviewer.

Anthropic: one request, two runsOne agent: 20 minutes and $9, the main feature did not work. An agent with a reviewer: 6 hours and $200, the result worked. With Opus 4.6: 3 hours 50 minutes and $124.70. It pays off on tasks the model does not do reliably alone.
Stripe: scaleMore than a thousand merged PRs a week are written by agents and reviewed by people. Steps without a model stand between model steps: linters in five seconds, at most two CI runs, then the branch goes to a person.
Spotify: the judgeVerifiers run by themselves, the agent does not know them; a judge checks the meaning. No before-and-after figures: only a veto in a quarter of sessions and recovery in half of those (the quote is in the previous section).
DORA 2025: speed and stabilityAI raises delivery speed but lowers stability. The argument “instability pays for itself through fast fixes” found no support. My conclusion: gates keep speed from being paid for with stability. The report does not mention gates.
Takeaway
In this exampleA reviewer and thresholds turned a broken application into a working one at 20 times the price. Stripe and Spotify gained scale thanks to checks that stand around the agent.
In generalA gate costs money and time. It pays off where the agent without it delivers a broken result or an error that is costly later.
Next stepFor your task, estimate the price of one error that reaches human review and the price of one check run. If the first is higher, the gate pays off.

How gates lengthen autonomous work: arithmetic and a gap in the data

A language model keeps a rough sketch of the world, not the world itself. When an agent checks its steps against reality (tests, system answers) and keeps its context in order, errors are found and fixed. Work on self-correction supports this: it helps with a reliable signal from outside and sometimes hurts without one. “The longer, the better” holds only with such checking: quality drops on long input, and on some tasks a longer chain of reasoning gives a worse answer. A gate provides the check and the order, so work can run longer without losing quality. There is no sample data for “a gate lengthened autonomous work”; below are the facts the idea rests on.

What a task horizon is. METR measures the length of a task an agent completes with a given probability of success, in the time a human needs for it. This is not the agent’s run time. For Claude Opus 4.6 the horizon at 50% success is about 12 hours (a confidence interval from 5 to 61 hours), and at 80% about 70 minutes. For GPT-5.4 it is 5.7 hours and 54 minutes. Above 16 hours METR considers measurements unreliable. How autonomy metrics work and where a person sits in them: in the article “Escalation to a human in AI agents”.

The price of reliability. Toby Ord showed that with a constant chance of failing per minute of work, the horizons are linked by a formula. The consequence: the horizon at 80% success is about a third of the one at 50%, at 90% about a seventh, at 99% about a seventieth. Each extra “nine” of reliability costs task length.

Chances of finishing, by number of steps held0%25%50%75%100%010203040steps in a row36%82%a gate catches 4 of 5 step errors (99% per step)no gate: 95% per stepA calculation assuming independent steps, not a measurement: the way Toby Ord models agent success rates● model, people, systems, data  ● agent and harness  ● risk, stop, boundary

A worked example: at 95% success per step, 36% chance remains after 20 steps, and at 99% per step 82%.

Where the gate is here. A gate on a step raises the step’s reliability. If a step fails with a 5% chance and the gate catches 4 errors out of 5 and sends the agent back to fix them, the step ends up breaking in 1% of cases. The arithmetic assumes independent steps: Ord himself notes that for Claude 3.7 Sonnet the measured ratio of horizons is 0.25 while the theory gives 0.32. The chart shows a direction: 82% is a calculation with no measured result behind it.

Two Anthropic mechanisms for long runs. The first: each agent session starts with no memory of earlier ones, and compacting the dialogue is not enough. So at the start the agent wrote a list of more than 200 features, all marked “failing”. The agent may change only the pass mark, and editing the tests themselves is forbidden. Such a list is gate state that lives in a file outside the dialogue: a new session sees how much remains and cannot decide that everything is done.

The second mechanism concerns “context anxiety”. Models start wrapping work up when they think the context window is about to end. A gate with criteria from the list makes the decision to finish depend on green marks, and the agent’s feeling takes no part in it. Hence the conclusion: a bounded context should be sized to fit into the physical context window.

A hook as a continuation mechanism. In Claude Code a task-completion hook does not let a task close until the checks pass: the refusal message returns to the agent, and it continues. A stop hook works the same way for finishing the whole turn.

Takeaway
In this exampleAn agent makes 20 steps. Without a gate the chance of getting through them without a single error is about 36%. A gate that catches 4 of 5 errors at every step lifts it, by the calculation, to about 82%.
In generalA gate gives autonomy through step reliability: the more rarely an error passes on, the longer the task you can leave unattended. There are no direct measurements, so this is a calculation and a hypothesis.
Next stepKeep a log: how many steps the agent passes without human intervention before and after adding a gate. In a month you will have your own numbers.

Where to put it: at a bounded-context border

A gate belongs at a bounded-context border for four reasons. Each has support in sources.

1. A check inside a frame is finite. No check can verify any program against any rule, so the check goes where a frame limits the question. Why this is so and how an aggregate border becomes a checkpoint is in the article “Where to check an AI agent’s work”. For a gate it follows: a gate without a border will answer “not sure” too often.

2. A small change succeeds more often. The more an agent changes at once, the less often the task is solved. A context border limits the size of a change naturally.

SWE-bench Live: share solved, by size of the reference changeone file, under 5 lines48%3+ files or 100+ linesunder 10%7 or more filesneverKozuchi agent, SWE-bench Verified: by size of its own change1–4 lines81.7%over 100 lines41.7%Different benchmarks and agents: do not compare bars across blocks, look at the direction● model, people, systems, data  ● agent and harness  ● risk, stop, boundary

The numbers on the chart come from two works: SWE-bench Live and the Kozuchi agent on SWE-bench Verified (arXiv 2608.15579). The benchmarks and agents differ, so the direction is what matters: the bigger the change, the less often it succeeds. At team level DORA shows the same: the benefit of AI depends on working in small batches.

On SWE-bench Live a change in one file under five lines is solved in almost half the cases (48%), three or more files or over a hundred lines in under 10%, and seven or more files never (arXiv 2505.23419). The Kozuchi agent on SWE-bench Verified solves 81.7% of tasks with a change of 1–4 lines and 41.7% with a change over 100 lines (arXiv 2608.15579). These are different benchmarks and agents, so the direction is what matters. DORA adds a team-level conclusion: the benefit of AI depends on working in small batches.

3. The context window is limited. Context is a finite resource with diminishing returns. Chroma tested 18 models and showed that reliability falls as input grows. In a 2024 talk Evans noted that a model’s answers are steadier when a request is broken into smaller chunks (as reported by InfoQ). A small bounded context gives the agent a short window, and the gate has less chance of checking something the agent no longer remembers.

Context “Booking”context window: only a little usedown agent, own set of functionsContext “Payment”context window: only a little usedown agent, own set of functionseventBookingCreatedgate on the borderMCP: create · cancel · listMCP: charge · refund · status● model, people, systems, data  ● agent and harness  ● risk, stop, boundary

Each context has its own agent, its own small window, its own set of MCP functions and a gate on the border. Events travel between contexts.

4. On the border it is clear who is to blame. In Bertrand Meyer’s design by contract a precondition violation is the caller’s bug and a postcondition violation is the supplier’s bug. A gate on the border shows at once whose bug it is: a bad command came in or a bad event went out. Evans advises putting a protective layer on the border that translates foreign concepts into your own. The gate stands on that layer.

What a bounded context and an aggregate are, and how the number of contexts relates to the number of agents, is in the articles “How many AI agents do you need” and “Specs by aggregate”.

Takeaway
In this exampleContexts “Booking” and “Payment”: each has its own agent, its own set of three MCP functions and its own gate. The event BookingCreated passes the booking gate on the way out and the payment gate on the way in. If payment rejected the event, it is visible on whose side the violation lies.
In generalA bounded-context border gives a gate four things at once: a finite check, a small change, a short window and a clear culprit.
Next stepPick one context and write three things on its border: which commands it accepts, which events it emits, which rule always holds. That is what the gate checks.

MCP: permissions, function set and the place of a gate

MCP is a protocol through which an agent calls functions of external systems. It matters twice for gates: an MCP server can hard-limit what is available to the agent, and the function set decides how much context the agent spends on descriptions.

What an MCP server can forbid and what it only suggests

MechanismStrengthWhat the specification says
Permissions and scopesa banwhen permissions are insufficient the server answers 403 and names the needed scope; in version 2026-07-28 the function list may depend on the caller’s permissions
Result by schemaa verdictthe server must return a result matching the declared schema, so a verdict “accepted / not accepted” is machine-readable
A question to a persona questionthe server may ask a person; the answer is accept, decline or cancel
Function labelsa hint“read-only”, “destructive” are hints, and the client need not trust them
Root foldersa hintthe server “should” respect the borders, but nothing enforces it

Confirmations from the specification: a result by schema, a function list by permissions and function labels. More on the scopes of MCP servers in Claude Code is in the article “MCP scopes”.

A narrow function set: two effects from one mechanism

Every functionOnly the needed ones≈ 55k tokens of descriptions≈ 8.7k tokensOpus 4 picks the right function: 49% → 74%● model, people, systems, data  ● agent and harness  ● risk, stop, boundary

Descriptions of 58 functions took about 55 thousand tokens. With search over functions the needed ones load on demand: about 8.7 thousand.

The first effect is context. Anthropic showed that 58 functions took about 55 thousand tokens, and about 8.7 thousand with search over functions, while the accuracy of picking a function rose for Opus 4 from 49% to 74% and for Opus 4.5 from 79.5% to 88.1%. In another example, running code instead of direct calls cut consumption from 150,000 to 2,000 tokens. Anthropic’s own conclusion: more functions do not mean a better result.

The second effect is permissions. The same settings limit permissions. In Claude Code a subagent has a list of allowed functions, a list of forbidden ones and its own set of MCP servers that the main dialogue does not have. One narrow set per bounded context means both a short window and less opportunity to break something. This is my conclusion: the figures above were measured for tokens, and none exist for security.

Why the gate stands behind MCP and why an agent has no incentive to stop

The author’s hypothesis, research in preparation. Agents are measured and, as I assume, optimised for autonomous run time: the main progress metric is the length of a task an agent does without a person (METR). MCP has a request to a person: the server may ask, and the answer is “accept”, “decline” or “cancel”. For such a metric every question to a person is a loss of autonomy, so an agent has no incentive to stop and ask. On top of that MCP is a narrow neck: calls to functions and their answers pass through it, but the meaning of the whole work does not. The conclusion: a gate cannot rest on the agent’s good will, it stands outside the agent, behind a separator. How agents are actually trained and how the metrics are counted I have not verified, and a separate article is devoted to it.

A kindred border runs between the agent’s commands (control plane) and the data it reads (data plane): data must not become commands. The author’s talk at Podlodka AI Crew is about this, “AI agent in production: architecture, protection, economics” (slides in Russian), and so is the article “Data plane and control plane of an agent”.

Where the gate should stand: outside the agent

A rule in the textA gate outside the agent“run the tests”!the agent may miss itadvice, not a banit cannot passa client hook or server permissions● model, people, systems, data  ● agent and harness  ● risk, stop, boundary

A rule in text the agent can bypass. A gate in a client hook or in server permissions it cannot.

Where the gate livesReliabilityWhy
A phrase in the instructionsadvicethe agent may skip it
A client hook before a calla banblocks a call to an MCP function by a pattern of server and function name
A stop hooka bandoes not let the turn end until the check passes
A hook after a calla signalthe function has already run
Server permissionsa banthe check stands in the system the agent calls

According to the Claude Code documentation: a hook before a call blocks the call, a stop hook does not let Claude finish the turn, and a task-completion hook does not let a task close. A hook after a call blocks nothing: the function has already run. A hint in text stays advice, as the author of an analysis of stop hooks notes. OWASP advises checking permissions where the action is executed.

A weak spot: a check the agent calls itself. If the check is an MCP function, the agent may call it or not, and then there is no verdict. The ready-made agent-gate server works this way: the agent sends the evidence itself, and the server returns a verdict and appends it to a log in which the entries are linked by hashes. That is self-checking with the blind spots from the self-grading section. The client is also required to treat function labels as untrusted. It is safer when a hook or an orchestrator calls the verdict server: the agent cannot bypass the verdict.

Which ready-made programs I did not find. MCP gateways cover permissions, secrets and leaks: agentgateway (a Linux Foundation project), and the Microsoft, Docker and Lasso gateways. I found no gate for “the work was done correctly” among them. Microsoft’s quality-gates set for spec-driven development turned out to be a checklist for the agent itself, with no server in it.

Takeaway
In this exampleThe agent is connected only to the functions of its context. A stop hook runs the tests and calls the booking-rules check server. The agent sees the error text but does not write the verdict itself.
In generalA narrow function set saves context and limits permissions, and a gate outside the agent does not let the check be bypassed. The verdict comes from a program the agent does not control.
Next stepFor one context, list the MCP functions the agent needs and disable the rest. Then set a hook that runs the check without the agent’s involvement.

Limits of a gate: how it is bypassed and why it breaks on its own

four paths around the gateEdits the test0.7%of o3 runs at METR,on one task21 of 21Special-cases the test54%GPT-5 in ImpossibleBench,read-only testsdo not cure itHides its intent95%caught by a reasoning monitor,under pressure recalldrops to near zeroReviewer gets used to it36.8%approvals instead of 30.1%over 7 months,11,429 reviewsA fifth path: a gate that keeps refusing — after 8 refusals in a row Claude Code ends the turn● model, people, systems, data  ● agent and harness  ● risk, stop, boundary

Four paths around a gate: editing a test, special-casing a test, hidden intent and a reviewer who got used to it.

The agent fits the result to the check. METR recorded that o3 cheated the evaluation in 0.7% of runs, and on one task 21 times out of 21. In the Claude 3.7 Sonnet system card Anthropic acknowledges that the model sometimes returns the test’s expected values instead of a general solution or edits the tests themselves. ImpossibleBench made tests contradict the task and counted any pass as cheating: GPT-5 cheated in 54% of cases. Read-only tests remove test editing but not special-casing.

Monitoring reasoning is better, but do not pressure it. An action monitor catches 60% of hacks, a reasoning monitor 95%. But if the agent is trained with pressure on its reasoning, the monitor’s recall falls to near zero, because the agent learns to hide its intent.

A gate that refuses forever. In Claude Code, after eight stop-hook refusals in a row the program ends the turn itself. The limit can be changed with an environment variable, but the principle stands: a gate needs an attempt limit and a handover to a person. At Stripe it is at most two CI runs, and Microsoft devsquad allows two correction attempts.

A gate that is too strict. According to InfoQ’s report of Spotify’s QCon London talk, published on 18 March 2026, the judge was found too rigid, blocked valid changes and was later removed, leaving checks in the prompts. This is a retelling, and I found no such statement in Spotify’s own posts. Cursor names the “integrator” role as a bottleneck.

The author’s heuristic: many relevant gates. I noticed that several gates, one per risk (types, tests, a linter, a check of meaning), work better than one big one. This is an observation; no source compares “one gate and many”. It fits what I found: Stripe alternates linters and CI, Sonar requires six conditions at once, Thoughtworks names compilers, linters and tests together. It does not cancel the limits above: each gate has a price and an attempt limit, and a gate that is too strict does harm, like Spotify’s judge. So “relevant” means tied to a risk that would otherwise reach the user.

The reviewer gets used to it. Over seven months, among 400 repeat reviewers the approval rate rose from 30.1% to 36.8%, the review queue slowed by 3.5 times and inline comments fell by 22% (arXiv 2606.22721, 11,429 reviews). According to Faros AI, among more than 10,000 developers using AI, PR size grew by 154% and review time by 91% (Faros AI, 23 July 2025).

Sensors do not see meaning. Böckeler notes that sensors catch misdiagnosis, needless complexity and misread tasks unreliably. A gate answers for what is written as a rule, and the rest stays with a person.

DangerDefence
The agent edits or bypasses teststests and the gate itself are read-only; only the check program sets the “passed” mark
Special-casing a testa second layer: a reviewing agent by meaning and random checks
The agent hides its intentwatch the reasoning but do not train the agent against it
The gate is red foreveran attempt limit, then a handover to a person
The gate blocks the correcttrack what share of refusals is wrong and loosen the rule
The reviewer got used to itshow the person only “not sure” cases and risk
Takeaway
In this exampleThe gate ran the tests, the agent disabled two flaky ones and got green. The check “the number of tests did not drop” caught the swap.
In generalEach gate has to be tested for bypass the way code is tested: what can the agent change to pass without doing the work.
Next stepClose the agent’s write access to the tests and to the gate configuration, and write the attempt limit into the gate itself.

How to start: five steps and ready prompts for the agent

Start with one context and one task. Each step below closes one item of the limits section. Prompts can be given to the agent as they are, with your project filled in.

1. Write “done” as a file

Create an acceptance.json file with a list of checkable “done” criteria for the task [description].
Each criterion: id, text, check command and a passes field set to false.
Rules: only the check script changes passes, and criteria are not deleted or edited without my confirmation.

2. Set a stop gate

Configure a Claude Code stop hook in .claude/settings.json: before a turn ends, run a check script
that executes the commands from acceptance.json and updates passes. If any criterion is red,
block the finish and return the error text to the agent. Check the stop_hook_active flag so the hook does not loop.
After three red attempts in a row, end the turn and tell me exactly what does not pass.

3. Close the bypasses

Forbid the agent to write to the tests directory, to acceptance.json and to .claude. Add a check that the number of tests
did not decrease and no test is marked as skipped.

4. Add a reviewer by meaning

Create a separate reviewing subagent with read-only access. It compares the final change with the original task
and scores each criterion from [list] from 0 to 5. Below 4 on any criterion means the change is not accepted.
Verdict: accepted, not accepted with a reason, or not sure.

5. Narrow the set of MCP functions

List the MCP functions the agent used in this context over the last month. Keep only those in this context’s
subagent settings and disable the rest. Show how many tokens were freed.

After that a loop works: each error the gate missed becomes a new check. This is the general principle from the article “Harness engineering in practice”, and a gate is its special case. And keep a log of verdicts: how many steps the agent passed without a person before the gate and after it. This is the very autonomy metric that research lacks.

Takeaway
In this exampleFive steps give a gate that is written in a file, started by a hook, does not let tests be bypassed, looks at meaning and stands on a narrow function set.
In generalThe first gate does not have to be clever. It is enough that the agent cannot say “done” itself and that the check stands outside it.
Next stepDo steps 1 and 2 for one task today. Add the rest as the gate misses errors.

Questions and answers

What are quality gates for AI agents?

A point where an agent’s work stops until an independent check answers “accepted”. The agent does not mark “done” itself: the answer comes from a machine, a reviewing agent or a person.

How does a gate differ from a test?

A test checks one rule and returns a result. A gate decides whether the work may go on, combines tests, a reviewing agent and a person into one decision, and can stop the agent.

Do gates increase an agent’s autonomous run time?

There are no direct measurements. There is arithmetic: at 95% success per step, 20 steps pass without an error in 36% of cases, and a gate that catches 4 of 5 errors lifts that to about 82%. And there are cases from Anthropic, Stripe and Spotify.

Where should a gate be placed?

Outside the agent and outside its context, in a client hook or in server permissions behind MCP. The agent itself works in a small bounded context: there a check is finite, the change is small and the set of MCP functions is narrow. A rule in instruction text remains only advice.
Facts: as of 14 November 2026, from the primary sources shown by ↗ marks and links in the text. The calculation on the autonomy chart is mine, assuming independent steps. The booking example is made up. Quotes about Spotify’s judge and its removal come from InfoQ’s report.
© 2026 Egor Urvanov