BlogCase Studies

Compliance as a service: a lending decline, rewritten

AgentGate Team8 min read

A lending assistant sends one sentence: Your loan application has been declined. It is accurate, polite, and it trips three rules at once. This article takes that sentence as a worked example of compliance as a service — what a deterministic rule engine finds in it, why each finding matters for a credit decision, and what the rewritten version looks like after it passes. The lender here is an illustration, not a real company, and the messages are illustrative text, not legal templates. Every call below uses the public API shape documented at agengate.com/docs.

The setup: one agent output, three gates

AgentGate sits between generation and delivery. The agent produces text; the text is posted to POST /v1/validate with an optional context object, an optional gates list and an optional policy. There is no model in the loop. The same text and the same ruleset always return the same verdict, which is what makes the check usable as a release gate rather than a second opinion.

The verdict is one of four: allow, redact, review or block. A missing-reason decline is not dangerous text, so it lands on review — the engine is saying the message is incomplete, not that it is unsafe.

curl https://agengate.com/v1/validate \
  -H "X-API-Key: ag_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "agent_output": "Your loan application has been declined.",
    "context": {
      "channel": "email",
      "product": "unsecured_personal_loan",
      "decision": "decline",
      "automated": true
    },
    "gates": ["explainability", "financial_conduct", "legal"]
  }'

The response carries the verdict, a status, the findings, the redacted output (null here, since nothing was redacted) and a receipt:

{
  "verdict": "review",
  "status": "completed",
  "findings": [
    {
      "rule": "EXP-004",
      "action": "review",
      "citations": ["GDPR Art. 13(2)(f)"]
    },
    {
      "rule": "LEG-007",
      "action": "review",
      "citations": ["GDPR Art. 22(3)"]
    },
    {
      "rule": "FIN-011",
      "action": "review",
      "citations": []
    }
  ],
  "redacted_output": null,
  "receipt": {
    "id": "rcpt_8f2c1a",
    "hash": "sha256:9b1e0c..."
  }
}

Rule identifiers follow the catalogue's naming convention; the authoritative and current list is the rule catalogue, which is public and grows over time. The citations array is a mapping from a rule to a provision — it is a pointer, not a compliance finding.

Reading the three findings

1. The decision states no reason (explainability)

A decline is an adverse action. The person is told the outcome and nothing else: no factor, no figure, no threshold. Under the GDPR, where automated decision-making is in play, the controller has to give meaningful information about the logic involved — Article 13(2)(f) for data collected from the person, Article 15(1)(h) for subject access. The rule engine cannot judge whether a stated reason is good; it can check whether a reason-shaped element exists at all. Here it does not.

2. There is no route to a human (legal)

Article 22 of the GDPR is a qualified right not to be subject to a decision based solely on automated processing that produces legal or similarly significant effects — it is not a ban on automated credit decisions. Where it applies, Article 22(3) requires safeguards: at least human intervention, the ability to express a point of view, and the ability to contest the decision. A one-line decline offers none of the three, and does not say whether a human was involved. If a credit analyst reviews every decline before it goes out, the message should say so; if nobody does, the message should offer the route.

3. There are no next steps (financial conduct)

Conduct expectations for retail credit communications generally turn on clarity, fairness and not misleading the customer — including telling them what happens next and what they can do. The one-liner ends the conversation. There is no reconsideration path, no reference to the data used, no indication of whether reapplying is worthwhile. This is the finding with the weakest legal citation and the strongest practical cost: it is the one that generates the support calls.

Three findings, three different gates, one sentence. That is the normal shape of the problem — agent outputs fail in several registers at once, and fixing them one register at a time is how decline copy ends up six paragraphs long and still wrong.

The rewrite that passes

The rewrite does three things: it names the reason with enough specificity to be checkable, it offers a human route and a data request, and it says who decided. Everything else is tone.

We could not approve your application for a 7,500 unsecured personal loan this time.

The main reason is your credit file shows two missed payments in the last 12 months.
Our affordability check also found 180 less available income each month than the 450
monthly repayment would require.

What you can do next:
- Ask for this decision to be reviewed by a person - reply to this email.
- Ask for the information used: your credit file data and the affordability calculation.
- Reapply after three months, or apply for a smaller amount.

This decision was prepared by an automated assessment. A member of the credit team
reviewed it before it was sent.

Re-running the same check with the new text:

curl https://agengate.com/v1/validate \
  -H "X-API-Key: ag_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "agent_output": "We could not approve your application for a 7,500 unsecured personal loan this time. The main reason is your credit file shows two missed payments in the last 12 months...",
    "context": {"channel": "email", "product": "unsecured_personal_loan", "decision": "decline", "automated": true},
    "gates": ["explainability", "financial_conduct", "legal"]
  }'
{
  "verdict": "allow",
  "status": "completed",
  "findings": [],
  "redacted_output": null,
  "receipt": {
    "id": "rcpt_3a91d7",
    "hash": "sha256:4c07ab..."
  }
}

Two caveats worth stating plainly. First, allow means the required elements are present, not that the reason is true, the numbers are right, or the tone is humane. A hallucinated reason passes the pattern check. Second, the rewrite is a structural illustration — the specific wording, the review claim and the three-month window are placeholders a lender would set against its own policy. The rule engine validates presence and shape; the substance still needs a human owner.

Where compliance as a service fits in the lending stack

The integration point is the last mile: between the model that drafted the message and the channel that sends it. Practically, that means a synchronous call inside the send path, with a timeout and a fail-closed policy — if the check does not return, hold the message rather than ship it unchecked.

Because the engine is deterministic, the same call works as a regression test. Keep a fixture file of representative agent outputs — declines, approvals, redaction cases, edge cases with unusual formatting — and assert the expected verdict in CI. A prompt change that quietly drops the reason line then fails the build instead of failing a customer. That property is what separates an AI compliance API from a second model in the loop: you can pin the result.

Three operational pieces matter after the first integration:

  • Overrides. POST /v1/overrides records a human decision to ship something the engine flagged, with a justification attached to the validation ID. Overrides are how you keep review from becoming a silent block — and the override log is usually the most interesting artefact in an audit.
  • Audit packages. POST /v1/audit-package bundles validations and receipts for a period or a policy, which is what you hand to an auditor or a regulator rather than a screenshot.
  • Scoping by gate. Not every message needs all eight gates. A marketing email and a decline letter have different exposure; the gates parameter keeps the noise down and the findings legible.

It is also worth being precise about what this layer is not. It is not a prompt-injection firewall and it does not inspect model inputs. It does not understand meaning; rules match patterns and will both miss things and false-positive. If your team is shopping for an LLM safety API that reasons about intent, this is a different tool — the value here is determinism and evidence, not comprehension. The same applies to framing it as an EU AI Act compliance tool: rules are mapped to provisions, and passing a check does not make a system compliant with any law.

For a decline flow specifically, the useful split is: pattern checks for the structural obligations (reason present, human route present, next steps present), human review for the substance, and receipts for both. That is the honest version of GDPR AI validation — you validate the artefacts you can pin down, and you document the judgement calls you cannot.

What the receipt proves, and what it does not

Every validation returns a receipt. It is SHA-256 hash-chained, signed with Ed25519, and contains a salted commitment to the text rather than the text itself — so the record does not become a second copy of the customer's decline letter sitting in a log. Anyone holding the receipt can check it at the receipt verifier without being given the original message.

What it establishes: at a specific time, a specific text was checked against a specific ruleset and produced a specific verdict, and the record has not been altered since. That is the chain-of-custody question auditors actually ask, and it is the part most teams cannot answer today.

What it does not establish: that the message is true, that the decision was correct, that a human really reviewed it, or that the lender is compliant with anything. A receipt is evidence of a check, not proof of fairness. Pair it with the override log and the audit package and you have a defensible record; on its own it is one link.

A checklist for decline messages before you ship

Distilled from the example above, in the order the rules tend to fire:

  1. Outcome stated plainly, with the product and amount named.
  2. Reason present and specific enough that a customer could dispute it — a factor plus a figure beats "our criteria".
  3. Human route offered, with a concrete action (reply, call, form) rather than "contact us".
  4. Data route offered: what was used and how to request it.
  5. Next steps including timing, so the customer knows whether reapplying is worth it.
  6. Decision provenance: automated, human-reviewed, or both — and say it truthfully.
  7. Consistency: the same template across channels, checked by the same ruleset, so email and in-app do not drift apart.

Each of these is a pattern the engine can test. None of them is a substitute for reading the message once as a human before the template ships. The useful division of labour is boring and reliable: rules for what must be present, people for whether it is any good, receipts for both.

Grab a free API key and post your own decline message to /v1/validate to see which rules it trips.

Share X LinkedIn Hacker News

All articles