Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Insurance Underwriting Agent — AWS Bedrock AgentCore Workshop

An AI-powered insurance underwriting assistant built with Amazon Bedrock AgentCore and the Strands Agent SDK. This project demonstrates how to build, deploy, secure, evaluate, and serve a production-grade AI agent on AWS — from prototype to customer-facing web interface.

Demo — Frontend in Action

Full Underwriting Assessment (APP-003 — Acme Manufacturing, $4M Commercial)

The agent pulls risk profile, claims history, compliance rules, and premium estimate — then delivers a structured recommendation:

Full Assessment

Claims History via Gateway (APP-005 — Delta Logistics)

Detailed claims data retrieved from external Lambda database through AgentCore Gateway:

Claims History

Session Memory & Context (Delta Logistics Review)

The agent remembers context within a session — "I'm reviewing the Delta Logistics account" carries forward:

Session Context


What This Agent Does

The Insurance Underwriting Agent helps underwriters:

  • Assess applicant risk profiles (auto, home, life, commercial)
  • Apply underwriting guidelines and state compliance rules
  • Calculate premium estimates with risk-adjusted rates
  • Query claims history from external databases
  • Make recommendations: APPROVE, CONDITIONAL APPROVE, or DECLINE

Architecture

┌─────────────────────────────────────────────────────────────────────────┐
│                        AgentCore Runtime (AWS)                           │
│                                                                         │
│   Browser / CLI ──→ Insurance Underwriting Agent                        │
│     (JWT Auth)         │         │           │              │           │
│                        ▼         ▼           ▼              ▼           │
│                   Tools 1-4   Exa MCP    AgentCore      AgentCore       │
│                   (local)     (web)      Memory         Gateway         │
│                                            │              │             │
└────────────────────────────────────────────│──────────────│─────────────┘
                                             │              │
                                             ▼              ▼
                                       Memory Store    Lambda: claims DB
                                             │
                                    ┌────────┴────────┐
                                    │   CloudWatch    │
                                    │   Traces/Logs   │
                                    │        │        │
                                    │        ▼        │
                                    │   Online Eval   │
                                    │   (LLM Judge)   │
                                    └─────────────────┘

Project Structure

InsuranceUnderwriting/
├── README.md                          ← You are here
├── docs/                              ← Lab guides (step-by-step)
│   ├── lab1-building-the-agent-prototype.md
│   ├── lab2-add-memory-to-your-agent.md
│   ├── lab3-scaling-tools-with-gateway.md
│   ├── lab4-securing-and-observing-in-production.md
│   ├── lab5-evaluating-agent-quality.md
│   ├── lab6-building-the-underwriter-interface.md
│   ├── Lab7-Governing-Agent-Actions-with-Policies.md
│   ├── Lab7.1-Guarding-Tool-Inputs-with-Semantic-Guardrails.md
│   └── Lab8-Zero-Code-Agents-with-AgentCore-Harness.md
├── app/InsuranceUnderwriting/         ← Runtime agent (Labs 1-7, custom Python)
│   ├── main.py                        ← Agent entrypoint (tools + system prompt)
│   ├── pyproject.toml                 ← Python dependencies
│   ├── memory/
│   │   └── session.py                 ← AgentCore Memory integration
│   ├── mcp_client/
│   │   └── client.py                  ← MCP client (Exa + Gateway)
│   ├── model/
│   │   └── load.py                    ← LLM model configuration
│   ├── tool/
│   │   ├── claims_schema.json         ← Gateway tool schema (ClaimsCheck Lambda)
│   │   └── claim_payout_schema.json   ← Gateway tool schema (ClaimPayout Lambda)
│   └── frontend/
│       ├── frontend.py                ← Flask web server
│       └── templates/index.html       ← Chat UI
├── app/OrderResearchAgent/            ← Harness agent (Lab 8, zero-code)
│   ├── harness.json                   ← Declarative config (model, tools, auth)
│   ├── system-prompt.md               ← System prompt
│   └── test_hitl.py                   ← Human-in-the-loop test script
├── app/PersistentReportAgent/         ← Bonus harness (session storage mount)
│   └── harness.json
├── app/ContainerAgent/                ← Bonus harness (custom container image)
│   └── harness.json
├── agentcore/                         ← Infrastructure config
│   ├── agentcore.json                 ← Project config (runtime, memory, gateway, auth, evals, policies)
│   ├── aws-targets.json               ← Deployment targets (account + region)
│   └── cdk/                           ← CDK infrastructure (auto-generated)
└── AGENTS.md                          ← AI coding assistant context

Workshop Labs

Each lab builds on the previous one. Follow them in order:

Lab Title What You Build Time
Lab 1 Building the Agent Prototype Agent with 4 local underwriting tools, deployed to AgentCore Runtime ~15 min
Lab 2 Add Memory to Your Agent Persistent memory (SEMANTIC + SUMMARIZATION) across sessions ~15 min
Lab 3 Scaling Tools with Gateway External claims database via AgentCore Gateway (Lambda as MCP tool) ~15 min
Lab 4 Securing and Observing in Production JWT authentication (Cognito), traces, logs, observability ~20 min
Lab 5 Evaluating Agent Quality Continuous quality monitoring with LLM-as-a-Judge evaluators ~15 min
Lab 6 Building the Underwriter Interface Web chat interface (Flask + AgentCore REST API with SSE streaming) ~20 min
Lab 7 Governing Agent Actions with Policies Cedar policies on Gateway — deterministic guardrails (payout limits, auth checks) ~20 min
Lab 7.1 Guarding Tool Inputs with Semantic Guardrails Bedrock Guardrails AI detecting EMAIL in tool arguments (semantic forbid policy) ~10 min
Lab 8 Zero-Code Agents with AgentCore Harness Declarative agent (no Python), Gateway + OAuth, shell access, HITL approval flows ~25 min

Total estimated time: ~2.5 hours

Prerequisites

  • AWS Account with Bedrock AgentCore access (us-east-1)
  • Node.js 20.x or later (for AgentCore CLI)
  • Python 3.10+ and uv (install uv)
  • AgentCore CLI installed: npm install -g @aws/agentcore-cli
  • AWS credentials configured (aws configure or environment variables)

Quick Start

# 1. Clone this repo
git clone https://github.com/<YOUR_USERNAME>/insurance-underwriting-agent.git
cd insurance-underwriting-agent

# 2. Install Python dependencies
cd app/InsuranceUnderwriting
uv sync
cd ../..

# 3. Deploy the agent
agentcore deploy -y -v

# 4. Test it
agentcore invoke "Get the risk profile for APP-001" --stream

# 5. Run the web interface (after completing Labs 1-6)
cd app/InsuranceUnderwriting/frontend
uv run python frontend.py
# Open http://localhost:8501

Key Technologies

Technology Role
Amazon Bedrock AgentCore Agent hosting, runtime, gateway, memory, evaluations
Strands Agents SDK Python agent framework with tool calling
Amazon Cognito JWT authentication for API access
AWS Lambda Claims database backend (Gateway target)
CloudWatch Traces, logs, and observability
Flask Web frontend server

AgentCore CLI Commands Used

Command Description
agentcore deploy -y -v Deploy agent + infra to AWS
agentcore invoke "prompt" --stream Test the deployed agent
agentcore status View deployment status
agentcore logs --since 5m View recent agent logs
agentcore traces list List recent traces
agentcore run eval --trace-id <id> Run quality evaluation
agentcore add memory Add memory to project
agentcore add gateway Add API gateway
agentcore add online-eval Add continuous evaluation

Agent Capabilities

Local Tools (defined in main.py)

  • get_underwriting_guidelines(line) — Returns rules for auto/home/life/commercial
  • get_applicant_risk_profile(id) — Retrieves applicant data (APP-001 through APP-005)
  • calculate_premium_estimate(id, amount) — Risk-adjusted premium calculation
  • check_compliance_rules(state, line) — State regulatory requirements

External Tools (via Gateway)

  • check_claims_history(id) — Detailed claims data from Lambda (dates, types, amounts)

Memory Strategies

  • SEMANTIC — Extracts and recalls facts about users across sessions
  • SUMMARIZATION — Summarizes conversations for context continuity

Sample Test Queries

# Basic tool usage
agentcore invoke "What are the underwriting guidelines for life insurance?" --stream

# Risk assessment
agentcore invoke "Get the risk profile for APP-001" --stream

# Premium calculation
agentcore invoke "Calculate premium for APP-004 with $2M life coverage" --stream

# Full assessment (uses multiple tools)
agentcore invoke "Do a complete underwriting assessment for APP-003 requesting $4M commercial coverage" --stream

Configuration

The main configuration is in agentcore/agentcore.json:

  • Runtime: Agent deployment settings (Python 3.14, HTTP protocol, network mode)
  • Memory: UnderwritingMemory with SEMANTIC + SUMMARIZATION strategies
  • Gateway: uw-gateway-secure with JWT auth, routes to Lambda claims function
  • Auth: CUSTOM_JWT authorizer using Cognito user pool
  • Evaluations: QualityMonitor (GoalSuccessRate, Correctness, ToolSelectionAccuracy at 100% sampling)

License

This project is part of an AWS workshop for educational purposes.

About

This is insurance underwriting agent developed at agentcore

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages