How to Build a claims processing Agent Using AutoGen in TypeScript for pension funds
A claims processing agent for pension funds takes a member’s claim, gathers the missing evidence, checks it against plan rules, flags exceptions, and prepares a decision packet for human review. It matters because pension operations are document-heavy, time-sensitive, and heavily regulated; the agent reduces manual back-and-forth without letting compliance or auditability slip.
Architecture
Build this agent as a small set of deterministic components around AutoGen, not one giant prompt:
- •
Claim intake layer
- •Receives claim requests from a portal, email parser, or case system.
- •Normalizes fields like member ID, benefit type, jurisdiction, and claim type.
- •
Policy retrieval layer
- •Pulls plan rules, eligibility criteria, and jurisdiction-specific requirements from a controlled knowledge base.
- •Keeps the agent grounded in approved pension policy text.
- •
AutoGen orchestration layer
- •Uses
AssistantAgentfor reasoning andUserProxyAgentfor tool execution and approval control. - •Coordinates document checks, missing-info requests, and decision drafting.
- •Uses
- •
Validation and rules engine
- •Verifies age thresholds, vesting status, contribution history, retirement date rules, and required evidence.
- •Never lets the model be the final authority on eligibility.
- •
Audit and case journal
- •Stores every prompt, tool call, retrieved policy snippet, and final recommendation.
- •Supports regulatory review and internal audit.
- •
Human review handoff
- •Routes exceptions, low-confidence cases, or adverse decisions to an operations analyst.
- •Keeps final benefit determinations under human control where required.
Implementation
1) Set up the AutoGen agents
Use AssistantAgent for the reasoning step and UserProxyAgent to execute tools. In pension workflows, keep tool execution explicit so you can log every action.
import { AssistantAgent } from "@autogen/agentchat";
import { UserProxyAgent } from "@autogen/agentchat";
import { OpenAIChatCompletionClient } from "@autogen/oai";
const modelClient = new OpenAIChatCompletionClient({
model: "gpt-4o-mini",
apiKey: process.env.OPENAI_API_KEY!,
});
const claimsAgent = new AssistantAgent({
name: "claims_agent",
modelClient,
systemMessage: `
You process pension claims.
Use only provided policy text and tool results.
If data is missing or ambiguous, request more information.
Never finalize an adverse decision without human review.
`,
});
const toolRunner = new UserProxyAgent({
name: "tool_runner",
humanInputMode: "NEVER",
});
2) Add deterministic tools for policy lookup and claim validation
This is where most teams get it wrong: they let the LLM infer eligibility. Don’t. Make the model call tools that return structured facts.
type ClaimInput = {
memberId: string;
claimType: "retirement" | "death" | "disability";
jurisdiction: string;
};
async function fetchPlanPolicy(claimType: string, jurisdiction: string) {
return {
claimType,
jurisdiction,
minRetirementAge: jurisdiction === "ZA" ? 55 : 60,
requiresProofOfIdentity: true,
requiresBankVerification: true,
requiresDeathCertificate: claimType === "death",
requiresMedicalEvidence: claimType === "disability",
dataResidency: "local-region-only",
};
}
async function validateClaim(input: ClaimInput) {
const policy = await fetchPlanPolicy(input.claimType, input.jurisdiction);
return {
eligibleForAutoReview: true,
missingDocuments: ["proof_of_identity"],
policy,
notes: [
"Member age must be verified against source-of-truth records.",
"Any adverse outcome must be reviewed by a case officer.",
],
};
}
3) Run the agent with a structured case prompt
The pattern is simple: send the claim facts plus retrieved policy text into the assistant, then require a concise decision memo. In production you’d wire this to your case management system.
async function processClaim() {
const input: ClaimInput = {
memberId: "M-1048821",
claimType: "retirement",
jurisdiction: "ZA",
};
const validation = await validateClaim(input);
const message = `
Claim:
${JSON.stringify(input)}
Validation:
${JSON.stringify(validation)}
Task:
1. Summarize what is missing.
2. Draft a next-action note for operations.
3. Do not make a final benefit determination.
`;
const result = await claimsAgent.generateReply([
{ role: "user", content: message },
]);
console.log(result);
}
processClaim().catch(console.error);
4) Put human approval around any exception path
For pension funds, exception handling is not optional. If the claim touches disputed service history, incapacity evidence, beneficiary disputes, or cross-border residency issues, stop automation and escalate.
| Scenario | Agent action | Required control |
|---|---|---|
| Missing ID or bank proof | Request documents | Auto-generated checklist |
| Age/service mismatch | Escalate | Human review |
| Death/disability claim | Gather evidence only | Case officer approval |
| Cross-border data transfer | Block external calls | Residency check |
Production Considerations
- •
Data residency
- •Keep member PII and medical evidence in-region if your fund or regulator requires it.
- •If you use hosted models, verify where prompts and logs are stored.
- •
Auditability
- •Persist the full conversation trace plus retrieved policy version IDs.
- •Record which tool produced each fact so auditors can reconstruct the decision path.
- •
Guardrails
- •Hard-block any final payout recommendation unless deterministic validation passes.
- •Use confidence thresholds to route complex cases to an analyst instead of letting the model guess.
- •
Monitoring
- •Track missing-document rates, escalation rates, false-positive eligibility flags, and average time-to-decision.
- •Alert on unusual spikes by claim type or jurisdiction; that often signals bad policy retrieval or upstream data issues.
Common Pitfalls
- •
Letting the model decide eligibility directly
- •Fix it by moving eligibility checks into code or rules services.
- •The agent should explain outcomes, not invent them.
- •
Skipping document provenance
- •Fix it by storing source references for every retrieved rule or uploaded document.
- •Pension audits will ask where each conclusion came from.
- •
Ignoring jurisdiction-specific requirements
- •Fix it by parameterizing policy by country or fund rule set.
- •Retirement age, tax treatment, beneficiary rights, and evidence requirements vary more than teams expect.
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