# Benchmark methodology

> How the Kavach agent benchmark is built and graded. Where the tasks come from, the arms that separate Kavach from workflow discipline, what agents cannot see, and how well Kavach's checks tell right builds from wrong ones.

The [agent benchmark](https://benchmark.kavachlabs.dev) asks one question: **does a coding agent ship more correct fixes and features when it can replay production evidence?** This page explains how the benchmark is built, so you can judge its results.

## Where the tasks come from

Tasks are real bugs and features from public repositories, not problems written for Kavach. We screened 613 problems from three public datasets against a fixed rubric:

| Source | Screened | Fit Kavach's model |
| --- | --- | --- |
| SWE-bench Multilingual | all 300 | 120 (40%) |
| Multi-SWE-bench, including SWE-bench Verified for Python | random sample of 200 | 37 (18%) |
| DeepSWE (Datacurve), feature track | all 113 | 51 (45%), with the bug-fix-only rule waived |

The screen is deliberately unflattering, and every problem is kept in the ledger, including the ones that do not fit, with the capability Kavach lacks for each:

- Only 11 of 613 fit as-is; the rest need a wrapper that feeds inputs to a stable entry point.
- Only 30 (4.9%) are service-shaped: handlers that fold state across requests, which is what Kavach is built for.
- A first pass judged every problem on its metadata; a verified pass read the issue, fix and tests of every candidate; a random 10% of the rejects were re-audited. The random draws use fixed seeds and can be reproduced.

From the fits, the benchmark uses two tracks:

- **Track A, incidents:** real bugs, mostly in Redis and Valkey, each turned into a recorded production fixture. The agent gets the bug report and must fix it.
- **Track B, features:** five feature tasks (`go-genai-streamed-function-args`, `httpx-deterministic-cookie-store`, `kombu-single-active-consumer-priority`, `kombu-virtual-queue-dead-lettering`, `updo-policy-alerting`). The agent gets the feature specification and must implement it.

## Arms

Every task runs in more than one arm, so a difference can be credited to the right cause.

| Arm | Track | The agent gets |
| --- | --- | --- |
| `control` | A and B | The repository at the base commit and the bug report or specification. |
| `workflow` | B | The same contract-first workflow as the Kavach arm, but with the project's own focused tests in place of `kavach contract check`. Separates Kavach from simply working in a disciplined way. |
| `kavach` | A and B | The base commit plus a Kavach integration, the `kavach` CLI and its MCP server. Track A adds the incident fixture; Track B adds a locked behaviour contract. |
| `kavach-implement` | B | The integration and tools, but no contract: the agent records traffic, writes invariants, and builds and locks the contract itself. Closer to real use. |

## How a run works

- **Same agent for every model.** Each attempt runs the same open-source agent, with the same tools and prompt; only the model changes. That makes open-weight and frontier models comparable, with and without Kavach.
- **Isolated containers.** The agent works in a container as a non-root user, with a one-hour limit by default. Its change is the `git diff` of its working tree.
- **Fresh grader.** A separate container applies the change to the same starting tree (ignoring any edits under `tests/`), builds it, and runs the grading.

## Grading

- **The grade is the hidden upstream test**: the test the project's maintainers wrote for the real fix or feature, which the agent never sees. A run passes when that test passes.
- **Kavach's verdict is recorded beside the grade but does not decide it.** Grading on Kavach's own check would make the Kavach arm grade itself.

## What the agent cannot see

- The hidden test, the candidate fixes and the task's notes live only in the grader image, or in no image.
- The source is a fresh repository with one commit (two in the Kavach arm), so `git log` reveals nothing after the base commit.
- The agent's web fetch tool is denied.

The container needs network access for the model API, so a shell command could still download the upstream fix. Transcripts are checked for this until network egress is limited to the model endpoint.

## Checking the checker

Before agents run, each task's reference solution and several deliberately wrong builds are graded by both Kavach and the hidden tests. Kavach should accept the reference and reject the wrong builds, including wrong builds the hidden tests let through.

Results across all five Track B tasks:

| Task | Build | `kavach contract check` | Hidden tests |
| --- | --- | --- | --- |
| go-genai-streamed-function-args | base | `unreached@31` | fail |
| | reference | `pass` | pass |
| | `client-scoped-state` (wrong) | `invariant_violated(streamed-call-args)@31` | **pass** |
| httpx-deterministic-cookie-store | base | `unreached@91` | fail |
| | DeepSWE reference | `invariant_violated(cookie-limits)@190` | pass |
| | reference with the limit check added | `pass` | pass |
| | `no-host-only-no-secure` | `invariant_violated(cookie-scope)@112` | fail |
| | `store-for-every-client` | `regression@13` | **pass** |
| kombu-single-active-consumer-priority | base | `unreached@137` | fail |
| | reference | `pass` | pass |
| | `no-cancel-guard` | `invariant_violated(cancel-callback-errors-contained)@265` | fail |
| | `last-consumer-dispatch` | `unreached@137` | fail |
| kombu-virtual-queue-dead-lettering | base | `unreached@244` | fail |
| | reference | `pass` | pass |
| | `no-property-cleanup` | `regression@661` | fail |
| | `x-death-no-count` | `invariant_violated(dead-letter-headers)@499` | fail |
| updo-policy-alerting | base | `unreached@2` | fail |
| | reference | `pass` | pass |
| | `unwired` | `invariant_violated(alert-payload)@56` | **pass** |
| | `wrong` | `invariant_violated(alert-delivery)@130` | fail |

What this shows:

- **Every reference implementation passes**, once DeepSWE's httpx reference is corrected. The contract check caught that the published reference skips the cookie-limit check on one path; adding that one call makes it pass.
- **Every wrong build is rejected**, including three (in bold) that the project's own hidden tests pass.
- **Builds that `kavach diff` alone could not tell apart are separated.** A feature changes outputs by design, so `diff` reports `diverged` for right and wrong builds alike; the contract check continues past the feature steps and catches the wrong ones.

For Track A, the same check runs on candidate fixes. Variants that change several fields of an input at once, or move values between positions, catch too-narrow fixes the recorded incident alone misses. They do not catch everything: on `redis-11734`, two wrong fixes still pass, because triggering them needs a key of another type or an input that does not fail on the old build.

## Known limits

- **Integration cost.** Kavach works only where the service records through an SDK. The benchmark's integrations were about 340 to 530 lines each.
- **Weak contracts pass weak code.** Thin traffic or vague invariants let wrong builds through. A person approving the contract is the only defence, and it is only as good as the review.
- **New outputs need judgement.** Invariants state properties; whether a changed output is exactly right is decided by the agent and the reviewer.
- **Nothing stops an agent approving its own contract.** The lock records that the contract changed, not who changed it.
- **Small task count.** Five feature tasks and a handful of incidents is enough to see where Kavach helps and fails, not to estimate an effect size precisely.

See the [live results](https://benchmark.kavachlabs.dev) for every run, and [Build a feature](https://www.thekavachlabs.com/docs/guides/build-a-feature) for the contract workflow the Track B arms use.

Source: https://www.thekavachlabs.com/docs/benchmark
