How to Build a claims processing Agent Using CrewAI in TypeScript for investment banking
A claims processing agent in investment banking takes incoming claim packets, classifies the claim type, extracts the relevant facts, checks policy and transaction context, and routes the case for approval or escalation. It matters because claims in this domain are not just operational tickets; they affect client trust, regulatory exposure, settlement timelines, and auditability.
Architecture
- •
Ingress layer
- •Receives claims from email, SFTP drops, internal case management systems, or API gateways.
- •Normalizes payloads into a single JSON contract before the agent sees them.
- •
Document extraction layer
- •Pulls structured fields from PDFs, scanned forms, trade confirmations, and correspondence.
- •Uses OCR plus deterministic parsers before handing text to the LLM.
- •
CrewAI orchestration layer
- •Uses
Agent,Task, andCrewto split work across specialized roles. - •One agent classifies, one validates against policy, one prepares the final decision memo.
- •Uses
- •
Compliance and audit layer
- •Captures every prompt, tool call, output, and human override.
- •Enforces data residency, retention rules, and least-privilege access.
- •
Decision routing layer
- •Sends low-risk claims to straight-through processing.
- •Escalates exceptions to a human reviewer with a full evidence bundle.
Implementation
1) Set up the project and dependencies
Use the TypeScript package for CrewAI plus a real LLM provider. Keep secrets out of code and load them from environment variables.
npm init -y
npm install @crewai/crew-ai dotenv zod
npm install --save-dev typescript ts-node @types/node
Create a strict tsconfig.json so bad payloads fail at compile time instead of in production.
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"outDir": "dist"
}
}
2) Define the agents and tasks
This pattern keeps responsibilities narrow. The classifier does intake triage, the validator checks policy constraints, and the writer produces an auditable decision note.
import 'dotenv/config';
import { Agent, Task, Crew } from '@crewai/crew-ai';
const intakeAgent = new Agent({
role: 'Claims Intake Analyst',
goal: 'Classify investment banking claims and extract key facts accurately',
backstory: 'You review client claims tied to trades, settlements, fees, and operational errors.',
});
const complianceAgent = new Agent({
role: 'Compliance Validator',
goal: 'Check claims against policy rules, KYC status, jurisdiction constraints, and escalation thresholds',
backstory: 'You ensure every recommendation is defensible under audit.',
});
const memoAgent = new Agent({
role: 'Decision Memo Writer',
goal: 'Produce a concise decision summary for human review or straight-through processing',
backstory: 'You write clear memos with evidence references and next actions.',
});
const classifyTask = new Task({
description:
'Classify this claim into one of: trade error, settlement delay, fee dispute, documentation issue, or fraud suspicion. Extract claimant name, account ID, trade reference if present, date range, amount claimed, and supporting documents.',
expectedOutput: 'Structured JSON with classification and extracted fields.',
agent: intakeAgent,
});
const validateTask = new Task({
description:
'Validate the claim classification against internal policy. Flag missing evidence, jurisdiction issues, sanctions risk indicators, and any amount above escalation threshold.',
expectedOutput: 'Validation result with risk flags and recommended route.',
agent: complianceAgent,
});
const memoTask = new Task({
description:
'Write a decision memo summarizing facts, validation findings, recommended action, and audit notes. Do not invent missing data.',
expectedOutput: 'Decision memo ready for case management upload.',
agent: memoAgent,
});
3) Run the crew with a real case payload
In investment banking you want deterministic input shaping before the model sees anything. Feed the crew a normalized claim object that already contains only approved fields.
async function main() {
const claim = {
claimId: 'CLM-2026-00192',
claimantName: 'Northbridge Capital',
accountId: 'ACCT-88341',
tradeReference: 'TRD-442901',
productType: 'Equity Swap',
claimedAmountUSD: 1250000,
jurisdiction: 'UK',
submittedAt: '2026-04-18T10:30:00Z',
documents: ['claim_form.pdf', 'trade_confirmation.pdf', 'email_thread.eml'],
narrative:
'Client alleges settlement delay caused missed financing window and requests reimbursement.',
};
const crew = new Crew({
agents: [intakeAgent, complianceAgent],
tasks: [classifyTask,, validateTask],
verbose: true,
});
}
main();
The above shows the shape of the orchestration. In practice you will also pass the output of one task into the next through your application layer if your CrewAI version does not chain task context automatically.
A complete production wrapper usually looks like this:
type ClaimInput = {
};
async function processClaim(claimInput) {
}
Production Considerations
- •
Deploy in-region
- •Keep model calls inside approved cloud regions that match your data residency policy.
- •For UK/EU clients under banking controls; do not ship raw claim documents across borders without legal approval.
- •
Log everything for audit
- •Store prompt versions,, tool outputs,, model responses,, timestamps,, user overrides.
- •
Make logs immutable enough for internal audit but redact PII where possible.
- •
Add hard guardrails
- •Reject claims lacking mandatory fields like account ID,, trade reference,, or document provenance.
- •Block recommendations when sanctions screening is unresolved or when confidence is below threshold.
- •
Human-in-the-loop for exceptions
- •Any fraud suspicion,, cross-border regulatory issue,, or high-value reimbursement should require manual sign-off.
- •The agent should prepare evidence; it should not be the final authority on payout decisions.
Common Pitfalls
- •
Letting the model see raw junk input
- •If you pass unparsed PDFs or email dumps directly into an agent; classification quality drops fast.
- •Normalize first with OCR,, schema validation,, and field-level redaction.
- •
Using one generic agent for everything
- •A single “claims bot” will mix intake,, compliance,, and memo writing badly.
- •Split roles so each task has one job and one failure mode.
- •
Skipping audit metadata
- •If you cannot reconstruct why a claim was escalated; you do not have a bank-ready system.
- •Persist task inputs,, outputs,, model version,, prompt template hash,, and reviewer actions.
For investment banking claims processing; CrewAI works best when it sits inside a controlled workflow rather than acting as an autonomous black box. Keep the LLM on narrow rails; keep compliance deterministic; keep humans in charge of final money movement.
Keep learning
- •The complete AI Agents Roadmap — my full 8-step breakdown
- •Free: The AI Agent Starter Kit — PDF checklist + starter code
- •Work with me — I build AI for banks and insurance companies
By Cyprian Aarons, AI Consultant at Topiax.
Want the complete 8-step roadmap?
Grab the free AI Agent Starter Kit — architecture templates, compliance checklists, and a 7-email deep-dive course.
Get the Starter Kit