How to Build a claims processing Agent Using CrewAI in TypeScript for wealth management
A claims processing agent for wealth management takes an incoming claim, extracts the relevant facts, checks them against policy and account context, routes exceptions, and produces an auditable decision package. It matters because claims in wealth management are rarely just “pay or deny” — they touch compliance, client trust, tax treatment, custodial records, and strict audit requirements.
Architecture
Build this agent as a small workflow, not a single prompt.
- •
Intake parser
- •Normalizes claim emails, PDFs, and structured forms into a single JSON shape.
- •Extracts claimant identity, account number, asset class, event type, and requested remedy.
- •
Policy retrieval layer
- •Pulls product rules, fee schedules, coverage clauses, and jurisdiction-specific constraints.
- •Keeps the agent grounded in approved policy text instead of model memory.
- •
Decision agent
- •Applies the policy to the claim facts.
- •Produces one of:
approve,reject,needs_review, with reasons and confidence.
- •
Compliance validator
- •Checks for KYC/AML flags, suitability issues, restricted jurisdiction handling, and disclosure requirements.
- •Forces escalation when regulated thresholds are crossed.
- •
Audit logger
- •Stores every input, tool call, retrieved policy snippet, and final output.
- •This is non-negotiable for wealth management.
- •
Case router
- •Sends complex cases to human ops or legal review.
- •Handles exceptions like missing documents or conflicting account ownership.
Implementation
1) Install CrewAI for TypeScript and define your case model
Use the TypeScript SDK and keep your data model explicit. Claims systems fail when they accept vague input shapes.
import { Agent } from "crewai";
import { Task } from "crewai";
import { Crew } from "crewai";
type ClaimCase = {
claimId: string;
clientId: string;
accountId: string;
jurisdiction: string;
claimType: "fee_dispute" | "trade_error" | "custody_loss" | "fraud";
amount: number;
narrative: string;
attachments: string[];
};
type ClaimDecision = {
outcome: "approve" | "reject" | "needs_review";
reason: string;
complianceFlags: string[];
};
const intakeAgent = new Agent({
role: "Claims Intake Analyst",
goal: "Extract structured claim facts from raw case data",
backstory: "You process wealth management claims with strict attention to completeness and auditability.",
});
const complianceAgent = new Agent({
role: "Wealth Compliance Reviewer",
goal: "Identify regulatory and policy risks in claims",
backstory: "You enforce jurisdictional rules, disclosure obligations, and escalation thresholds.",
});
const decisionAgent = new Agent({
role: "Claims Decision Maker",
goal: "Decide whether a claim should be approved, rejected, or escalated",
backstory: "You apply policy consistently and produce concise reasoning for audit trails.",
});
2) Create tasks that force structured outputs
CrewAI works best when each task has one job. Don’t ask one agent to parse facts, interpret policy, and decide everything at once.
const extractTask = new Task({
description:
"Extract the key facts from the claim case into a clean JSON summary. Include claimant identity signals, jurisdiction risk, claim type, amount, and missing fields.",
expectedOutput:
'{"claimId":"string","summary":"string","missingFields":["string"],"riskSignals":["string"]}',
});
const complianceTask = new Task({
description:
"Review the extracted claim facts against wealth management compliance constraints. Flag AML/KYC issues, restricted jurisdictions, documentation gaps, and any reason this must be escalated.",
expectedOutput:
'{"complianceFlags":["string"],"escalate":true,"reason":"string"}',
});
const decisionTask = new Task({
description:
"Using the case facts and compliance findings, decide whether the claim is approve, reject, or needs_review. Return a decision with a short audit-ready rationale.",
expectedOutput:
'{"outcome":"approve|reject|needs_review","reason":"string","complianceFlags":["string"]}',
});
3) Wire the crew execution path
For production systems you want deterministic orchestration around the crew. Keep execution behind a service boundary so you can add retries, logging, and persistence.
export async function processClaim(caseData: ClaimCase): Promise<ClaimDecision> {
const crew = new Crew({
agents: [intakeAgent, complianceAgent, decisionAgent],
tasks: [extractTask, complianceTask, decisionTask],
process: "sequential",
});
const result = await crew.kickoff({
inputs: {
claimId: caseData.claimId,
clientId: caseData.clientId,
accountId: caseData.accountId,
jurisdiction: caseData.jurisdiction,
claimType: caseData.claimType,
amount: caseData.amount,
narrative: caseData.narrative,
attachments: caseData.attachments,
},
});
return result as unknown as ClaimDecision;
}
4) Add audit logging before you expose it to operations
Wealth management teams need traceability across decisions. Log inputs and outputs in an immutable store with retention controls aligned to your regulator and internal policy.
async function handleIncomingClaim(caseData: ClaimCase) {
const startedAt = Date.now();
const decision = await processClaim(caseData);
await auditLog.write({
caseId: caseData.claimId,
system: "claims-processing-agent",
inputHash: hash(JSON.stringify(caseData)),
outputHash: hash(JSON.stringify(decision)),
outcome: decision.outcome,
complianceFlags: decision.complianceFlags,
durationMs: Date.now() - startedAt,
timestampUtc: new Date().toISOString(),
});
return decision;
}
Production Considerations
- •
Deploy in-region
- •Keep customer data in approved regions only.
- •If you operate across EMEA/US/APAC portfolios, separate workloads by residency boundary.
- •
Make every decision auditable
- •Persist raw input, retrieved policy text versioning, model output, and human override history.
- •Use immutable storage or WORM-style retention where required.
- •
Add hard guardrails
- •Block automatic approval for high-value claims above your control threshold.
- •Force escalation on sanctions hits, PEP matches, missing beneficial ownership data, or cross-border tax ambiguity.
- •
Monitor drift by product line
- •A custody-loss claim behaves differently from a fee dispute.
- •Track approval rate by jurisdiction and asset class so you catch policy drift early.
Common Pitfalls
- •
Letting the model decide without policy grounding
- •This creates inconsistent outcomes across similar cases.
- •Fix it by retrieving approved policy text first and keeping decisions tied to versioned rules.
- •
Skipping structured outputs
- •Free-form responses are hard to route into downstream systems.
- •Fix it by forcing JSON-shaped task outputs and validating them before persistence.
- •
Ignoring exception handling for regulated cases
- •A claim can look routine but still involve sanctions exposure or fiduciary conflict.
- •Fix it by routing any flagged case to human review instead of letting the agent finalize it.
- •
Treating audit as an afterthought
- •In wealth management that becomes a control failure fast.
- •Fix it by logging every step with timestamps, hashes, policy versions, and final disposition.
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