How to Build a claims processing Agent Using AutoGen in TypeScript for retail banking
A claims processing agent in retail banking takes in a customer claim, checks the policy or account context, gathers missing details, routes the case to the right internal team, and produces an auditable decision trail. It matters because claims are high-volume, time-sensitive, and regulated; if you get automation wrong here, you create compliance risk, operational delay, and customer churn.
Architecture
- •
Customer intake layer
- •Receives claim data from web forms, branch systems, or CRM events.
- •Normalizes fields like customer ID, incident type, amount, date, and jurisdiction.
- •
Policy and account retrieval tools
- •Pulls account status, product terms, transaction history, and eligibility rules from internal systems.
- •Must enforce least-privilege access and tenant-aware authorization.
- •
AutoGen agent orchestration
- •Uses an
AssistantAgentto reason over the claim. - •Uses a
UserProxyAgentto execute tool calls and enforce human approval for sensitive outcomes.
- •Uses an
- •
Decisioning and escalation layer
- •Classifies claims into approve, request more info, deny, or escalate to manual review.
- •Keeps hard stops for fraud signals, sanctions hits, and high-value claims.
- •
Audit logging and evidence store
- •Persists prompts, tool outputs, model decisions, timestamps, and approver identity.
- •Required for regulatory review and internal dispute handling.
- •
Compliance guardrails
- •Redacts PII where possible.
- •Blocks unsupported advice and ensures decisions stay within policy rules.
Implementation
- •Install AutoGen for TypeScript and wire up your model client
Use the TypeScript package that exposes AssistantAgent, UserProxyAgent, and OpenAIChatCompletionClient. Keep the model client configurable so you can pin models per environment.
npm install @autogenai/autogen openai
import { AssistantAgent, UserProxyAgent } from "@autogenai/autogen";
import { OpenAIChatCompletionClient } from "@autogenai/autogen/openai";
const modelClient = new OpenAIChatCompletionClient({
model: "gpt-4o-mini",
apiKey: process.env.OPENAI_API_KEY!,
});
const claimsAgent = new AssistantAgent({
name: "claims_agent",
modelClient,
systemMessage: `
You are a retail banking claims processing agent.
Classify claims into APPROVE, NEEDS_INFO, ESCALATE_REVIEW, or DENY.
Never make final decisions on fraud or sanctions-related cases.
Always cite which policy fields or account facts were used.
`,
});
const opsProxy = new UserProxyAgent({
name: "ops_proxy",
});
- •Expose bank-approved tools for claim lookup and case creation
AutoGen works best when the agent can call narrow tools instead of inventing facts. In retail banking, that means explicit functions for fetching account data and opening a case in your workflow system.
type ClaimInput = {
claimId: string;
customerId: string;
amount: number;
incidentType: string;
};
async function fetchAccountContext(customerId: string) {
// Replace with internal API call
return {
status: "ACTIVE",
product: "Retail Checking",
jurisdiction: "SG",
recentDisputes: 0,
kycStatus: "VERIFIED",
};
}
async function createCase(payload: Record<string, unknown>) {
// Replace with case management API
return { caseId: `CASE-${Date.now()}`, status: "OPEN" };
}
- •Run the agent conversation with tool execution and approval gates
The pattern below keeps the assistant focused on analysis while the proxy executes approved actions. For claims above a threshold or with missing evidence, route to human review instead of auto-decisioning.
async function processClaim(input: ClaimInput) {
const context = await fetchAccountContext(input.customerId);
const task = `
Process this retail banking claim:
claimId=${input.claimId}
customerId=${input.customerId}
amount=${input.amount}
incidentType=${input.incidentType}
accountStatus=${context.status}
product=${context.product}
jurisdiction=${context.jurisdiction}
kycStatus=${context.kycStatus}
Return:
1) decision
2) rationale
3) missing information if any
4) whether human review is required
`;
const result = await opsProxy.initiateChat(claimsAgent, task);
const text = result.messages.map(m => m.content).join("\n");
if (text.includes("ESCALATE_REVIEW") || input.amount > 5000) {
return createCase({
claimId: input.claimId,
decisionDraft: text,
reviewRequired: true,
jurisdiction: context.jurisdiction,
});
}
return createCase({
claimId: input.claimId,
decisionDraft: text,
reviewRequired: false,
jurisdiction: context.jurisdiction,
});
}
processClaim({
claimId: "CLM-10021",
customerId: "CUST-7781",
amount: 1200,
incidentType: "unauthorized_card_transaction",
}).then(console.log);
- •Add structured output validation before anything reaches production
Do not trust free-form text for downstream workflow routing. Parse the agent response into a strict schema and reject anything that does not match your allowed decision set.
type ClaimDecision =
| "APPROVE"
| "NEEDS_INFO"
| "ESCALATE_REVIEW"
| "DENY";
type ParsedDecision = {
decision: ClaimDecision;
};
function parseDecision(rawText: string): ParsedDecision {
const match = rawText.match(/(APPROVE|NEEDS_INFO|ESCALATE_REVIEW|DENY)/);
if (!match) throw new Error("Invalid agent decision");
return { decision: match[1] as ClaimDecision };
}
Production Considerations
- •
Deploy regionally
- •Keep model inference and logs in-region to satisfy data residency requirements.
- •For multi-country retail banking stacks, separate jurisdictions by deployment boundary.
- •
Log everything needed for audit
- •Persist prompt inputs, retrieved account facts, tool outputs, final decision text, approver identity, and timestamps.
- •Make logs immutable or append-only for dispute resolution.
- •
Add hard guardrails
- •Block auto-denial when fraud indicators are present. - Require human approval above configurable thresholds. - Redact account numbers, national IDs, and card PANs before sending text to the model.
- •
Monitor drift and exception rates - Track approval rate by product line and jurisdiction. - Alert on spikes in escalations or invalid outputs. - Sample decisions weekly against policy changes.
Common Pitfalls
- •
Letting the model decide outside policy
- •Fix it by constraining outcomes to a small enum and rejecting unsupported responses.
- •Claims agents should classify within policy; they should not invent bank rules.
- •
Passing raw PII into prompts
- •Fix it by masking customer identifiers and only sending necessary fields.
- •Use internal tools for sensitive lookups instead of dumping entire records into context.
- •
Skipping human review on edge cases
- •Fix it with explicit thresholds for amount, fraud flags, sanctions matches, jurisdictional exceptions, or missing evidence.
- •In retail banking, “mostly right” is not good enough when a regulator asks who approved the claim.
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