Check an agent's file before you accept it

An agent saying its file is complete doesn't make it so. Write down what the file must satisfy, using expected values from the source rather than from the agent, and run those checks with acceptance_gate. It passes only when every check passes, and it returns each check's result so you can see which one failed.

What goes in a contract

A contract is a list of checks. Each check names a tool and its arguments, exactly as you would call that tool on its own. You can also give a check a label of up to 100 characters. The gate returns the label with the check's status: pass, fail or error. New contracts should use reconcile. Five legacy aliases remain supported until 2026-12-26 for older clients:

Tool What it checks
reconcile Two-list reconciliation by ID and integer cents, or one-list row count, exact sum, unique IDs and required fields.
row_count Legacy alias (until 2026-12-26): the list has the number of rows you expect.
unique_ids Legacy alias (until 2026-12-26): a named ID field has no duplicates and no blanks.
required_fields Legacy alias (until 2026-12-26): a record has the fields you name, and none of them is null.
exact_sum Legacy alias (until 2026-12-26): amounts add up to an expected total, in integer cents.
reconcile_records Legacy alias (until 2026-12-26): two lists pair up by ID with equal amounts. See Reconcile two lists by ID.

A contract can hold up to 20 checks, per the tool's input schema.

A contract that passes

Say an agent produced a three-invoice file. From the billing system, you know there should be 3 invoices totaling 1,650.39. The contract checks the count and total, the IDs, and one record's fields using reconcile:

{
  "checks": [
    {
      "tool": "reconcile",
      "label": "Row count and total",
      "arguments": {
        "rows": [
          {
            "invoice": "INV-1001",
            "customer": "Acme",
            "total": "1250.00"
          },
          {
            "invoice": "INV-1002",
            "customer": "Birch",
            "total": "310.40"
          },
          {
            "invoice": "INV-1003",
            "customer": "Cove",
            "total": "89.99"
          }
        ],
        "expected_row_count": 3,
        "amount_field": "total",
        "expected_total": "1650.39"
      }
    },
    {
      "tool": "reconcile",
      "label": "Unique invoice IDs",
      "arguments": {
        "rows": [
          {
            "invoice": "INV-1001"
          },
          {
            "invoice": "INV-1002"
          },
          {
            "invoice": "INV-1003"
          }
        ],
        "id_field": "invoice",
        "check_unique_ids": true
      }
    },
    {
      "tool": "reconcile",
      "label": "Required fields",
      "arguments": {
        "record": {
          "invoice": "INV-1002",
          "customer": "Birch",
          "total": "310.40"
        },
        "required_fields": [
          "invoice",
          "customer",
          "total"
        ]
      }
    }
  ]
}
{
  "pass": true,
  "checks": [
    {
      "index": 0,
      "tool": "reconcile",
      "label": "Row count and total",
      "status": "pass",
      "result": {
        "pass": true,
        "checks": {
          "row_count": {
            "pass": true,
            "observed": 3,
            "difference": 0
          },
          "exact_sum": {
            "pass": true,
            "total": "1650.39",
            "difference": "0.00"
          }
        }
      }
    },
    {
      "index": 1,
      "tool": "reconcile",
      "label": "Unique invoice IDs",
      "status": "pass",
      "result": {
        "pass": true,
        "checks": {
          "unique_ids": {
            "pass": true,
            "duplicate_ids": [],
            "missing_rows": []
          }
        }
      }
    },
    {
      "index": 2,
      "tool": "reconcile",
      "label": "Required fields",
      "status": "pass",
      "result": {
        "pass": true,
        "checks": {
          "required_fields": {
            "pass": true,
            "missing": []
          }
        }
      }
    }
  ],
  "receipt": {
    "version": "0.4.0",
    "checked_at": "2026-11-26T14:17:54.033Z",
    "vantage": "cloudflare:IAD",
    "input_sha256": "957bd41845b5a5e1b6fa8851025d91ba874d39b1673002430fe2e8454a90fcae"
  }
}

A contract that fails

Now the agent's file has two problems: the third row repeats invoice INV-1002, and the customer on the second row is null. The same contract runs on that file:

{
  "checks": [
    {
      "tool": "reconcile",
      "label": "Row count and total",
      "arguments": {
        "rows": [
          {
            "invoice": "INV-1001",
            "customer": "Acme",
            "total": "1250.00"
          },
          {
            "invoice": "INV-1002",
            "customer": null,
            "total": "310.40"
          },
          {
            "invoice": "INV-1002",
            "customer": "Cove",
            "total": "89.99"
          }
        ],
        "expected_row_count": 3,
        "amount_field": "total",
        "expected_total": "1650.39"
      }
    },
    {
      "tool": "reconcile",
      "label": "Unique invoice IDs",
      "arguments": {
        "rows": [
          {
            "invoice": "INV-1001"
          },
          {
            "invoice": "INV-1002"
          },
          {
            "invoice": "INV-1002"
          }
        ],
        "id_field": "invoice",
        "check_unique_ids": true
      }
    },
    {
      "tool": "reconcile",
      "label": "Required fields",
      "arguments": {
        "record": {
          "invoice": "INV-1002",
          "customer": null,
          "total": "310.40"
        },
        "required_fields": [
          "invoice",
          "customer",
          "total"
        ]
      }
    }
  ]
}
{
  "pass": false,
  "checks": [
    {
      "index": 0,
      "tool": "reconcile",
      "label": "Row count and total",
      "status": "pass",
      "result": {
        "pass": true,
        "checks": {
          "row_count": {
            "pass": true,
            "observed": 3,
            "difference": 0
          },
          "exact_sum": {
            "pass": true,
            "total": "1650.39",
            "difference": "0.00"
          }
        }
      }
    },
    {
      "index": 1,
      "tool": "reconcile",
      "label": "Unique invoice IDs",
      "status": "fail",
      "result": {
        "pass": false,
        "checks": {
          "unique_ids": {
            "pass": false,
            "duplicate_ids": [
              "INV-1002"
            ],
            "missing_rows": []
          }
        }
      }
    },
    {
      "index": 2,
      "tool": "reconcile",
      "label": "Required fields",
      "status": "fail",
      "result": {
        "pass": false,
        "checks": {
          "required_fields": {
            "pass": false,
            "missing": [
              "customer"
            ]
          }
        }
      }
    }
  ],
  "receipt": {
    "version": "0.4.0",
    "checked_at": "2026-11-26T14:17:55.152Z",
    "vantage": "cloudflare:IAD",
    "input_sha256": "be290b7effe132dc6e657e57b692056d06e74b9a010f551e2616f1be16a6c0dc"
  }
}

The gate fails, and the checks array shows why: a duplicate ID and a missing customer. The row count and the total still pass. A file can have the right number of rows and the right total and still be wrong, which is why a contract should check more than one thing.

Where the expected values come from

The gate compares the file against the numbers in your contract. If the agent that made the file also writes the expected count or total, a wrong file can pass against a wrong expectation. Take expected values from the source system, the client's order or another record you trust.

The gate also checks only what you declare. required_fields looks only at the field names you list, and it doesn't judge whether the values are correct.

What the gate rejects

An empty contract returns a structured EMPTY_LIST error. Treat an error as "not accepted".

{
  "error": {
    "code": "EMPTY_LIST",
    "path": "checks",
    "got": "array with 0 items",
    "expected": "array with at least one item",
    "fix": "Send at least one item.",
    "example": [
      {
        "tool": "exact_sum",
        "arguments": {
          "amounts": [
            "0.30"
          ],
          "expected": "0.30"
        }
      }
    ]
  },
  "receipt": {
    "version": "0.4.0",
    "checked_at": "2026-11-26T14:17:56.232Z",
    "vantage": "cloudflare:IAD",
    "input_sha256": "eb974a7f5ec1b337afeb736d5f5f55eb466edf8c0efbe67fec328b9db844faf1"
  }
}

A check that names a tool outside the allowed tools above, such as margin_price, gets status: "error" with an UNSUPPORTED_CHECK error. A check with bad arguments also gets status: "error". The gate keeps running the other checks and the overall result is "pass": false. Here the labeled sum check sends an amount with three decimal places, and the row count still runs:

{
  "checks": [
    {
      "tool": "reconcile",
      "label": "Invoice total",
      "arguments": {
        "amounts": [
          0.123
        ],
        "expected_total": "1250.00"
      }
    },
    {
      "tool": "reconcile",
      "arguments": {
        "rows": [
          {
            "invoice": "INV-1001"
          }
        ],
        "expected_row_count": 1
      }
    }
  ]
}
{
  "pass": false,
  "checks": [
    {
      "index": 0,
      "tool": "reconcile",
      "label": "Invoice total",
      "status": "error",
      "error": {
        "code": "INVALID_AMOUNT",
        "path": "checks[0].arguments.amounts[0]",
        "got": "0.123 (number)",
        "expected": "decimal string or finite number with up to 15 integer digits and 2 fractional digits",
        "fix": "Send the same value as a quoted plain decimal using ASCII digits and a decimal point. Remove grouping separators and currency symbols without changing the amount. Values exceeding 15 integer digits or 2 fractional digits are unsupported.",
        "example": "0.30"
      }
    },
    {
      "index": 1,
      "tool": "reconcile",
      "status": "pass",
      "result": {
        "pass": true,
        "checks": {
          "row_count": {
            "pass": true,
            "observed": 1,
            "difference": 0
          }
        }
      }
    }
  ],
  "receipt": {
    "version": "0.4.0",
    "checked_at": "2026-11-26T14:17:57.319Z",
    "vantage": "cloudflare:IAD",
    "input_sha256": "1b762fc36cf1be0c407e64d7d216d2e06f6c43143f9e23d47c78df124a21d79f"
  }
}

Zero, false and blank strings count as present

The required_fields option on reconcile flags a field only when it's missing or null. This check passes:

{
  "checks": [
    {
      "tool": "reconcile",
      "arguments": {
        "record": {
          "id": "A",
          "qty": 0,
          "paid": false,
          "note": ""
        },
        "required_fields": [
          "id",
          "qty",
          "paid",
          "note"
        ]
      }
    }
  ]
}
{
  "pass": true,
  "checks": [
    {
      "index": 0,
      "tool": "reconcile",
      "status": "pass",
      "result": {
        "pass": true,
        "checks": {
          "required_fields": {
            "pass": true,
            "missing": []
          }
        }
      }
    }
  ],
  "receipt": {
    "version": "0.4.0",
    "checked_at": "2026-11-26T14:17:58.383Z",
    "vantage": "cloudflare:IAD",
    "input_sha256": "5d581628f7c11dbcab69d5e5a7642fd3298fe5381119d7f60151b5f405351846"
  }
}

If a blank string should count as missing in your data, check for it separately.

Call it over MCP

curl -sS https://mcp.agenttoolyard.com/mcp \
  -H 'content-type: application/json' \
  -H 'accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"acceptance_gate","arguments":{"checks":[{"tool":"reconcile","arguments":{"amounts":["1250.00","310.40","89.99"],"expected_total":"1650.39"}},{"tool":"reconcile","arguments":{"rows":[{"invoice":"INV-1001"},{"invoice":"INV-1002"},{"invoice":"INV-1003"}],"expected_row_count":3}}]}}}'

The gate's result comes back as JSON text in result.content[0].text (captured from the live server, v0.4.0):

{
  "pass": true,
  "checks": [
    {
      "index": 0,
      "tool": "reconcile",
      "status": "pass",
      "result": {
        "pass": true,
        "checks": {
          "exact_sum": {
            "pass": true,
            "total": "1650.39",
            "difference": "0.00"
          }
        }
      }
    },
    {
      "index": 1,
      "tool": "reconcile",
      "status": "pass",
      "result": {
        "pass": true,
        "checks": {
          "row_count": {
            "pass": true,
            "observed": 3,
            "difference": 0
          }
        }
      }
    }
  ],
  "receipt": {
    "version": "0.4.0",
    "checked_at": "2026-11-26T14:17:59.642Z",
    "vantage": "cloudflare:IAD",
    "input_sha256": "11be540fd5fa7206ba6387c7f7d29d4c3faf28e7f24e3157900e1406f741e62f"
  }
}

For headers, protocol versions and error codes, see the MCP docs. To add the server to a client, see Add AgentToolyard to an MCP client.

FAQ

Can the agent write its own contract?

It can draft the list of checks, but the expected values should come from you or a source you trust. Otherwise a wrong file can pass against a wrong expectation.

Can I add margin or pricing checks to the gate?

No. New contracts should use reconcile. The five legacy aliases (row_count, unique_ids, required_fields, exact_sum and reconcile_records) are kept for older clients until 2026-12-26. Any other tool gets a check-level UNSUPPORTED_CHECK error, and commercial calculators are not available on the MCP server.

How many checks can one contract hold?

Up to 20.

Does a passing gate mean the file is correct?

It means the file met every check you declared. It says nothing about anything you didn't check. In the failing example above, the row count and total passed while the IDs and a customer field were wrong.

What if one check has bad arguments?

That check gets status: "error" and an error such as INVALID_AMOUNT. The other checks still run. Treat the contract as not accepted.

Try the acceptance gate in the playground.