Objective
Adjusters spend 40–60% of their time looking across systems for policy clauses, prior claims by the same VIN/provider, and fraud signals. In this recipe you'll seed a tiny claims database, embed policy documents, and call a claims-adjuster persona via SELECT AGENT_RUN('claims-adjuster', 'review claim …') — the agent reads the claim, retrieves policy by meaning, and recommends an action with citations. One process, one transaction, one query.
Requires: SynapCores v1.6.6.9+ (
AGENT_RUNSQL function). Configure[query.ai_service]with a tool-capable model (recommended:qwen2.5-coder:7bvia Ollama, or any OpenAI/Anthropic endpoint).
Step 1: Create the claims + policy tables
CREATE TABLE IF NOT EXISTS recipe_ins_claims (
claim_id INTEGER PRIMARY KEY,
policy_number TEXT,
vin TEXT,
provider TEXT,
amount DOUBLE,
description TEXT,
filed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS recipe_ins_policy_docs (
doc_id INTEGER PRIMARY KEY,
section TEXT,
body TEXT,
embedding VECTOR(384)
);
Step 2: Seed claims + policy clauses
INSERT INTO recipe_ins_claims (claim_id, policy_number, vin, provider, amount, description) VALUES
(1001,'P-AAA-001','VIN-9912','Acme Body Shop', 3200.00,'Rear-end collision, bumper replacement'),
(1002,'P-AAA-001','VIN-9912','Acme Body Shop', 3850.00,'Same vehicle, hail damage'),
(1003,'P-AAA-001','VIN-9912','Acme Body Shop', 4100.00,'Same vehicle, alleged theft of stereo'),
(1004,'P-BBB-077','VIN-2210','Citywide Auto', 1800.00,'Side mirror replacement after parking-lot incident'),
(1005,'P-CCC-411','VIN-7733','Reliable Repair',12500.00,'Total loss after flood');
INSERT INTO recipe_ins_policy_docs (doc_id, section, body) VALUES
(1,'Collision Coverage','Collision coverage applies to physical damage caused by impact with another vehicle or object. Standard deductible is $500 unless rider 3.b applies. Excludes damage during commercial use.'),
(2,'Comprehensive — Weather','Hail, flood, and lightning damage fall under Comprehensive (not Collision). Filing must occur within 30 days of the event. Documentation required: photographs and a contemporaneous police or weather-service report.'),
(3,'Comprehensive — Theft','Theft claims require a police report filed within 48 hours of discovery. Sound-system theft over $500 requires receipts or a registered installation record. Repeated theft claims from a single vehicle within 12 months trigger fraud review.'),
(4,'Total Loss','A vehicle is deemed a total loss when repair cost exceeds 80 percent of market value. Settlement is at market value minus the deductible; salvage rights pass to the insurer.'),
(5,'Fraud Indicators','Three or more claims on the same VIN within 90 days, or claims from the same provider exceeding 5 in 12 months, are referred to Special Investigations Unit.');
Step 3: Embed the policy
UPDATE recipe_ins_policy_docs SET embedding = EMBED(body);
Step 4: Ground truth — recall policy by meaning
SELECT section,
COSINE_SIMILARITY(embedding, EMBED('claim for hail damage on a sedan')) AS sim
FROM recipe_ins_policy_docs
ORDER BY sim DESC
LIMIT 2;
Expected: Comprehensive — Weather ranks first.
Step 5: Ground truth — fraud signal via plain SQL
SELECT vin, COUNT(*) AS n_claims, SUM(amount) AS total
FROM recipe_ins_claims
GROUP BY vin
HAVING COUNT(*) >= 3;
Expected: VIN-9912 appears with 3 claims — the fraud rule from §5 of the policy is matched.
Step 6: Hand the whole job to the agent
SELECT AGENT_RUN(
'aidb-assistant',
'Review claim 1003 in the recipe_ins_claims table. Use rag_search against recipe_ins_policy_docs to find the relevant policy clauses. Use execute_query to check whether VIN-9912 has other recent claims that might indicate a fraud pattern. Recommend an action and cite the policy sections you used.'
) AS recommendation;
Expected reply (paraphrased): claim 1003 is a stereo-theft claim that requires §3 (police report + receipts) and triggers §5 (3+ claims on same VIN). Recommendation: refer to SIU before settling.
Cleanup
DROP TABLE IF EXISTS recipe_ins_claims;
DROP TABLE IF EXISTS recipe_ins_policy_docs;
Use it from your agent (framework-agnostic)
- REST/SDK: call
POST /v1/query/executewith the Step-6 SQL. The agent runs server-side; you get the recommendation as a JSON column. - MCP: point any MCP client at
ws://<host>/mcp?token=<jwt>and call thequerytool with the same SQL. - Pattern:
AGENT_RUNruns the whole agentic loop inside one transaction — the policy retrieval, the fraud-signal SQL, and the LLM reasoning all see the same snapshot of the data. No stitched stack, no eventual-consistency window.
Key Concepts Learned
EMBED()+COSINE_SIMILARITY()give you semantic policy lookup in one table.AGENT_RUN(persona, task)makes the agent loop a first-class SQL primitive — composable withJOIN,WHERE, and CTEs.- The same database that holds the data also holds the agent's reasoning surface — no separate vector store, no separate cache, no separate orchestration layer.