Check an invoice for duplicates before the agent pays
check_duplicate_invoiceSpend gate for invoices: decides whether an agent may pay this invoice, with a signed receipt as proof. Same as judge with one duplicate check: it compares this invoice with the invoices this caller recorded earlier and also judges it. Call it before an agent pays or approves an invoice or payment instruction. Inputs: the judge inputs (task, agent_output as the invoice JSON, evidence, criteria, checks, mode, tags) plus duplicate {vendor_path, invoice_id_path, amount_path, currency_path?, date_path?, payee_account_path?, accept_payee_change?, window_days?, store?, retain_days?}. Returns the judge result plus duplicate.status (unique, duplicate, possible_duplicate, replay or not_checked). On duplicate or possible_duplicate, next_step.action is escalate: do not pay. Fingerprints are kept per caller; only keyed HMAC fingerprints are stored, and only when store is true. Cost: 1 call, the same as judge. First 3 calls per UTC day need no key (daily private IP namespace). Then use Authorization: Bearer , or a per-call payment in params._meta with no key (records are kept per payer; an unverified payment returns the payment requirements again). A free key covers 10 calls per UTC day (get_api_key or https://screwtape.ai/signup/). After the shared 3/day anonymous allowance (3/minute, global 2000/day), tools/call without a key or payment is HTTP 200 with isError true and the payment requirements in structuredContent.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"task": "<task>",
"agent_output": "<agent_output>",
"duplicate": "<duplicate>"
},
"name": "check_duplicate_invoice"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | Optional. blocking (the default) is today's behaviour. advisory computes the same verdict, checks, next_step and receipt, then adds mode, decision_owner human, recommended_action (approve, review or return) and a notice. The receipt signs mode advisory as schema_version 5. Same price. | |
| task | Yes | The original instruction or question the agent was answering. | |
| share | No | Optional. false keeps this call out of opt-in data sharing even when the key has sharing on. It cannot turn sharing on. | |
| checks | No | Optional. The worker runs each check. A failed check forces verdict fail. Types include url_contains, json_schema, equals, regex, numeric, required_fields, types, format, sum and duplicate. duplicate (at most 1) compares an invoice with ones this caller recorded earlier and stores keyed fingerprints only when store is true. At most 3 url_contains checks. Local checks run first; if one fails, no model is called and next_step says what to fix. | |
| retain | No | Optional. true stores this call for 24 hours; requires an API key. Default false stores nothing. | |
| version | No | Optional version tag for that agent. At most 64 characters. | |
| agent_id | No | Optional tag for the agent making this call. 1 to 64 characters: letters, digits, and . _ : -. This is not the per-answer agent_id on a consensus answer. | |
| criteria | No | Optional. Facts or terms the answer must contain, one per string. | |
| evidence | No | Optional. Source passages the answer must be grounded in, one string per passage. Without evidence, grounding cannot be checked. | |
| duplicate | Yes | The duplicate check: dot paths into agent_output for vendor, invoice id and amount, plus optional currency_path, date_path, payee_account_path, accept_payee_change, window_days, store and retain_days. payee_account_path remembers the vendor's bank or payee account; a change escalates with payee_account_changed. store true records this invoice's keyed fingerprints so later calls can match it. | |
| agent_output | Yes | The invoice or payment instruction the agent is about to pay, as a JSON string. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | Present only when the call sent mode: advisory. | |
| model | No | ||
| score | Yes | null when no model gave a verdict (degraded). | |
| checks | No | ||
| claims | No | ||
| engine | No | groq, workers_ai, deterministic, or demo. Also signed into the receipt. | |
| notice | No | Advisory only. Fixed text: the call does not approve, hold or release any payment. | |
| reasons | Yes | ||
| receipt | No | ||
| verdict | Yes | ||
| version | No | Echoed when the call sent a version tag. | |
| agent_id | No | Echoed when the call sent an agent_id tag. | |
| degraded | No | ||
| duplicate | No | Present only when the call sent a duplicate check. status is unique, duplicate, possible_duplicate, replay or not_checked. Carries no invoice data. | |
| next_step | No | ||
| retention | No | ||
| request_id | Yes | ||
| fail_closed | No | Present and true only when a finance check failed closed because the primary model was unavailable. Treat it as review. | |
| verification | No | ||
| decision_owner | No | Advisory only. A person owns the decision. | |
| receipt_reason | No | ||
| recommended_action | No | Advisory only, deterministic and not signed. Judge: next_step pass is approve, escalate is review, retry is return (send back to the agent). Consensus: risk low is approve, medium or high is review. |