Agentic FinServ Compliance Reviewer

A compliance-reviewer agent that walks the transaction table, consults KYC docs and regulations by meaning, surfaces hits with citations, and drafts an SAR-style write-up — all in SQL via AGENT_RUN.

All recipes· agents· 12 minutesintermediateen
Instance: localhost:8080

Opens your running SynapCores (Agentic FinServ Compliance Reviewer will be staged for a preview — nothing runs until you click Run). No instance yet? Install free in ~30s.

Share

Objective

Quarterly compliance reviews are weeks of human ticking against transactions, KYC docs, and regulatory updates. In this recipe you set up a tiny FinServ database with wires, KYC notes, and regulation snippets, then ask a compliance-reviewer persona to audit Q2 wires for PEP exposure via SELECT AGENT_RUN(...). The full audit trail — every query the agent ran, every doc it touched, every regulation it cited — stays in the same database that holds the answer.

Requires: SynapCores v1.6.6.9+ (AGENT_RUN). Configure a tool-capable model in [query.ai_service] (recommended: qwen2.5-coder:7b via Ollama).

Step 1: Create transactions + KYC + regulation tables

CREATE TABLE IF NOT EXISTS recipe_fs_wires (
  wire_id        INTEGER PRIMARY KEY,
  customer_id    INTEGER,
  counterparty   TEXT,
  country        TEXT,
  amount_usd     DOUBLE,
  posted_at      TIMESTAMP
);

CREATE TABLE IF NOT EXISTS recipe_fs_kyc (
  customer_id    INTEGER PRIMARY KEY,
  legal_name     TEXT,
  pep_status     TEXT,         -- 'clear' | 'self' | 'family' | 'associate'
  risk_rating    TEXT,         -- 'low' | 'medium' | 'high'
  notes          TEXT
);

CREATE TABLE IF NOT EXISTS recipe_fs_regs (
  reg_id      INTEGER PRIMARY KEY,
  section     TEXT,
  body        TEXT,
  embedding   VECTOR(384)
);

Step 2: Seed

INSERT INTO recipe_fs_wires VALUES
 (5001,1,'Acme Imports GmbH','DE', 240000.00,'2026-04-12 09:31:00'),
 (5002,1,'Acme Imports GmbH','DE',  9800.00,'2026-04-14 10:02:00'),
 (5003,1,'Acme Imports GmbH','DE',  9800.00,'2026-04-14 10:04:00'),
 (5004,1,'Acme Imports GmbH','DE',  9800.00,'2026-04-14 10:09:00'),
 (5005,2,'BlueOak Trading Ltd','UK', 18500.00,'2026-04-18 14:11:00'),
 (5006,3,'Polaris Holdings','VG', 145000.00,'2026-04-22 08:55:00');

INSERT INTO recipe_fs_kyc VALUES
 (1,'Marcus Klein','clear','medium','Long-standing import client. EU.'),
 (2,'Susan Wright','self','high','Listed on national PEP list (former minister).'),
 (3,'Anonymous Director, Polaris Holdings','associate','high','BVI shell. UBO opaque. Politically exposed associate of named individual.');

INSERT INTO recipe_fs_regs (reg_id, section, body) VALUES
 (1,'BSA Structuring','Multiple cash or wire transactions in close succession that individually fall below the $10,000 reporting threshold but in aggregate exceed it are presumed to be structuring under 31 USC 5324. SAR filing is required where the pattern is identified.'),
 (2,'OFAC Sanctions','Transactions involving counterparties in sanctioned jurisdictions or sanctioned individuals are prohibited. Verify against OFAC SDN list before posting.'),
 (3,'PEP Enhanced Due Diligence','Customers identified as Politically Exposed Persons (PEPs), or their family members or close associates, are subject to enhanced due diligence including source-of-funds review and senior compliance approval for transactions over $50,000.'),
 (4,'High-Risk Jurisdictions','Wires to or from FATF high-risk jurisdictions or known offshore secrecy havens (BVI, Cayman, Panama, certain others) require additional documentation and explicit risk-based review.'),
 (5,'Beneficial Ownership','Where the beneficial owner of a counterparty is unclear or shielded by nominee directors, escalate for UBO investigation before processing transactions above $25,000.');

Step 3: Embed the regulations

UPDATE recipe_fs_regs SET embedding = EMBED(body);

Step 4: Ground truth — structuring detector (plain SQL)

SELECT customer_id, DATE(posted_at) AS day, COUNT(*) AS n_wires, SUM(amount_usd) AS total
FROM recipe_fs_wires
WHERE amount_usd < 10000
GROUP BY customer_id, DATE(posted_at)
HAVING COUNT(*) >= 3;

Expected: customer 1 triggers — three sub-$10k wires on 2026-04-14, total > $29k.

Step 5: Ground truth — semantic regulation lookup

SELECT section,
       COSINE_SIMILARITY(embedding, EMBED('multiple sub-threshold wires same day')) AS sim
FROM recipe_fs_regs
ORDER BY sim DESC
LIMIT 2;

Expected: BSA Structuring is the top match.

Step 6: Hand the audit to the agent

SELECT AGENT_RUN(
  'aidb-assistant',
  'You are a FinServ compliance reviewer. Audit Q2 wires in recipe_fs_wires for PEP exposure and structuring. Use execute_query on recipe_fs_wires JOIN recipe_fs_kyc to find PEP-flagged customers and any sub-$10k clustering. Use rag_search on recipe_fs_regs to cite the regulations you apply. Output a short memo with: findings, customers and wires implicated, regulation citations, and a recommended next step (e.g., draft SAR, escalate, clear).'
) AS audit_memo;

Cleanup

DROP TABLE IF EXISTS recipe_fs_wires;
DROP TABLE IF EXISTS recipe_fs_kyc;
DROP TABLE IF EXISTS recipe_fs_regs;

Use it from your agent

  • REST/SDK: the Step-6 SQL via POST /v1/query/execute returns the audit memo as a TEXT column. The agent's intermediate queries are written to the gateway audit log.
  • MCP: call the query tool over ws://<host>/mcp?token=<jwt> with the same SQL.
  • Why in-DB matters here: the regulator's question is "show every query the agent ran, with timestamps and parameters." SynapCores keeps that trail in the same database that produced the memo. Stitched stacks scatter it across 3–5 systems.

Key Concepts Learned

  • AGENT_RUN composes with the rest of SQL — your audit pipeline can be a CTE, a view, or a scheduled job.
  • The agent picks tools (execute_query vs rag_search) based on what the task needs — not on what the orchestrator hard-codes.
  • Audit-grade traceability is a free byproduct of running the agent loop inside the database.

Tags

ai-agentagent-runfinservcompliancekycragsaraudit

Run this on your own machine

Install SynapCores Community Edition free, paste the SQL or Cypher above into the bundled web UI, and watch it run.

Download Free CE