How to Build a claims processing Agent Using CrewAI in Python for investment banking

By Cyprian AaronsUpdated 2026-04-21
claims-processingcrewaipythoninvestment-banking

A claims processing agent in investment banking takes incoming claim documents, extracts the relevant facts, checks them against policy and transaction records, flags exceptions, and routes the case for approval or rejection. It matters because claims in this domain are not just operational tickets; they can trigger financial loss, regulatory exposure, and audit scrutiny if the decision trail is weak or inconsistent.

Architecture

  • Ingestion layer

    • Accepts claim packets from email, SFTP, case management systems, or internal APIs.
    • Normalizes PDFs, scans, JSON payloads, and attachments into a common structure.
  • Extraction agent

    • Pulls out claimant identity, trade references, dates, amounts, counterparties, and supporting evidence.
    • Uses deterministic parsing first, then LLM extraction for messy documents.
  • Validation agent

    • Checks the claim against internal records: trade confirmations, settlement logs, KYC/AML flags, and policy rules.
    • Detects missing fields, duplicate submissions, and out-of-policy requests.
  • Compliance reviewer agent

    • Applies banking-specific controls: escalation thresholds, sanctions screening references, retention requirements, and approval hierarchy.
    • Produces an audit-ready rationale for every decision.
  • Decision orchestrator

    • Coordinates the agents using CrewAI.
    • Writes the final outcome into a case system with traceable reasoning and source citations.
  • Audit and logging layer

    • Stores prompts, outputs, tool calls, timestamps, model versions, and human overrides.
    • Required for internal audit and regulatory review.

Implementation

1. Install dependencies and define your crew roles

Use CrewAI’s Agent, Task, Crew, and Process classes. For banking workflows, keep each agent narrow; do not create one “smart” agent that does everything.

from crewai import Agent, Task, Crew, Process
from crewai.llm import LLM

llm = LLM(model="gpt-4o-mini")

extractor = Agent(
    role="Claims Extraction Analyst",
    goal="Extract structured claim data from incoming documents with high accuracy.",
    backstory="You work on investment banking operations claims and prioritize traceability.",
    llm=llm,
    verbose=True,
)

validator = Agent(
    role="Claims Validation Analyst",
    goal="Validate extracted claims against policy rules and transaction records.",
    backstory="You verify claims using bank controls and flag exceptions for review.",
    llm=llm,
    verbose=True,
)

compliance = Agent(
    role="Compliance Reviewer",
    goal="Assess claims for regulatory risk and produce an audit-ready recommendation.",
    backstory="You enforce banking compliance requirements and document every decision.",
    llm=llm,
    verbose=True,
)

2. Create tasks with explicit outputs

In claims processing, vague task definitions cause bad decisions. Make each task produce a structured artifact that downstream tasks can consume.

extract_task = Task(
    description="""
Extract the following from the claim packet:
- claimant_name
- claim_id
- trade_reference
- transaction_date
- claimed_amount
- currency
- counterparty
- supporting_documents
Return valid JSON only.
""",
    expected_output="A JSON object containing normalized claim fields.",
    agent=extractor,
)

validate_task = Task(
    description="""
Validate the extracted claim against internal rules:
- amount must be positive
- trade_reference must exist in records
- transaction_date must be within policy window
- duplicate claims must be flagged
Return JSON with validation_status, violations, and notes.
""",
    expected_output="A JSON object with validation results.",
    agent=validator,
)

compliance_task = Task(
    description="""
Review the validated claim for compliance concerns:
- escalation_required true/false
- reason_codes array
- audit_summary string
Return JSON only.
""",
    expected_output="A JSON object with compliance recommendation.",
    agent=compliance,
)

3. Assemble the crew and run sequentially

For regulated workflows like claims adjudication, use Process.sequential so each stage is deterministic and auditable. That gives you a clean chain of custody from extraction to compliance review.

crew = Crew(
    agents=[extractor, validator, compliance],
    tasks=[extract_task, validate_task, compliance_task],
    process=Process.sequential,
    verbose=True,
)

result = crew.kickoff(inputs={
    "claim_packet": """
Claim ID: CLM-10492
Claimant: Orion Capital Markets
Trade Ref: TRD-88321
Date: 2025-03-12
Amount: USD 250000
Counterparty: Northbridge Securities
Documents: confirmation.pdf; email_thread.txt
"""
})

print(result)

4. Add tool access for record lookup

Real claims agents need tools for internal systems. CrewAI supports tools through its tool ecosystem; use them to query approved sources instead of asking the model to guess.

from crewai_tools import tool

@tool("lookup_trade_record")
def lookup_trade_record(trade_reference: str) -> str:
    """
    Look up a trade record in an approved internal system.
    Replace this stub with a real API call behind your network controls.
    """
    records = {
        "TRD-88321": '{"status":"settled","amount":"250000","currency":"USD"}'
    }
    return records.get(trade_reference, '{"status":"not_found"}')

Attach this tool to the validation agent when you wire production access:

validator.tools = [lookup_trade_record]

Production Considerations

  • Data residency

    • Keep claim payloads inside approved regions.
    • If you operate across jurisdictions, pin model endpoints and storage to region-specific infrastructure.
  • Auditability

    • Log prompt inputs, retrieved records, model outputs, task transitions, and human overrides.
    • Store immutable audit trails keyed by claim ID and timestamp.
  • Guardrails

    • Enforce schema validation on every task output before it reaches downstream systems.
    • Reject non-JSON responses where JSON is required.
    • Add policy checks for maximum payout thresholds and mandatory human approval above limits.
  • Monitoring

    • Track extraction accuracy, exception rates, average handling time, escalation rate, and override rate.
    • Alert on sudden changes in duplicate detection or missing-field frequency; those usually indicate upstream document drift or prompt regression.

Common Pitfalls

  1. Using one agent for extraction and approval

    • This makes reasoning opaque and hard to audit.
    • Split extraction from validation from compliance review so each step has a clear responsibility.
  2. Letting the model infer missing facts

    • In banking claims work, guessing is failure.
    • Force tool lookups or mark fields as missing; never let an LLM invent trade references or amounts.
  3. Skipping structured outputs

    • Free-form text breaks downstream automation fast.
    • Require JSON at each step and validate it before moving to the next task.
  4. Ignoring regulatory evidence requirements

    • If you cannot reconstruct why a claim was approved or rejected six months later, the workflow is not production-ready.
    • Persist source documents references plus every intermediate decision artifact.

Keep learning

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

Related Guides