AI Agents
OpenInsure runs AI workloads as Cloudflare Durable Objects backed by the agents npm package (^0.7.5). Each agent is a stateful, long-lived object that can hold WebSocket connections, maintain conversation history, and coordinate with other agents via the OrchestratorAgent.
Architecture
Section titled “Architecture”POST /v1/... or WebSocket │ ▼ OrchestratorAgent (DO) │ ┌────┴──────────────────────────────────┐ │ │ ▼ ▼SubmissionAgent UnderwritingAgent ClaimAgent ... │ │ │ ▼ ▼ ▼EmailIntakeAgent WorldIntelligence AdjudicationAgentAll agents share:
- Model: Claude (
claude-sonnet-4-6for reasoning,claude-haiku-4-5for fast extraction) - Observability: Langfuse for tracing every prompt, response, tool call, and latency
- State: Durable Object SQLite for conversation history and task state
Agent Inventory
Section titled “Agent Inventory”| Durable Object | Purpose |
|---|---|
SubmissionAgent | Processes new business submissions end-to-end |
PolicyAgent | Mid-term policy actions (endorsements, cancellations) |
ClaimAgent | Claims workflow automation and AI-assisted investigation |
UnderwritingAgent | Risk assessment, rate justification, referral drafting |
AdjudicationAgent | Coverage determination and denial letter drafting |
BordereauxAgent | Automated bordereaux generation and carrier submission |
ComplianceAgent | Regulatory deadline tracking and filing automation |
ProducerAgent | Producer onboarding and licensing workflow |
TelematicsAgent | Telematics data ingestion and risk scoring |
LossControlAgent | Loss prevention recommendations |
WorldIntelligenceAgent | External risk data enrichment (weather, FMCSA, news) |
EmailIntakeAgent | Shared mailbox parsing and routing |
NotificationAgent | Intelligent notification dispatch and scheduling |
CollaborationAgent | Deal Room real-time collaboration |
AssemblyAgent | Document assembly and form population |
OrchestratorAgent | Multi-agent task coordination |
OpenInsureMCP | MCP server for external AI integrations |
DealRoomDO | WebSocket-backed carrier deal room |
Submission Automation
Section titled “Submission Automation”The SubmissionAgent handles the full intake-to-quote workflow when triggered by either the producer portal or the email ingest cron.
Email intake flow
Section titled “Email intake flow”EmailIntakeAgentreceives a new message fromUnderwriting@mhcmga.comvia Graph API 2. Classifies the email (new submission, renewal, endorsement request, general inquiry) 3. Extracts attachments and stores them in R2 4. InvokesAssemblyAgentto extract structured data from ACORD forms using Workers AI + Claude 5. Creates a draft submission record in PlanetScale with extracted fields 6. Notifies the UW queue via the Notification system
Risk narrative generation
Section titled “Risk narrative generation”For every new submission, UnderwritingAgent generates an AI risk narrative using Claude:
// Simplified — actual implementation in packages/agentsconst narrative = await agent.generateRiskNarrative({ submission, lossHistory, industryBenchmarks,});// Output: structured risk summary with flagged items,// recommended premium adjustment (-5% to +5%), and// adverse action notice if adjustment is negativeThe narrative is attached to the submission record and displayed in the Underwriting Workbench.
Claims AI
Section titled “Claims AI”ClaimAgent provides AI assistance throughout the claims lifecycle:
| Feature | Description |
|---|---|
| Coverage determination | Analyzes the policy form and loss facts, drafts a coverage opinion |
| Reserve estimation | Suggests initial reserve based on loss type, jurisdiction, and injury severity |
| Fraud signal detection | Flags patterns from the loss description and claimant history |
| Settlement recommendation | Benchmarks against comparable closed claims |
| Denial letter drafting | Generates state-compliant denial letters from coverage position |
World Intelligence
Section titled “World Intelligence”WorldIntelligenceAgent enriches submissions and claims with external data:
- FMCSA — Motor carrier safety data for commercial auto and transportation risks
- Weather — Storm and catastrophe data for property claims (NOAA integration)
- News — Adverse media scan for named insureds on large commercial submissions
- NCCI — Workers’ Compensation experience modification factor lookup
- ISO — PPC (Public Protection Classification) for property risks
Observability
Section titled “Observability”All agent activity is traced in Langfuse (us.cloud.langfuse.com). Every trace includes:
- Agent type and DO ID
- Input prompt (sanitized — no PII)
- Model used and token counts
- Tool calls and results
- Latency per step
- Submission / policy / claim ID for correlation
Set LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY via wrangler secret put to enable tracing.
Model Selection
Section titled “Model Selection”| Use case | Model | Reason |
|---|---|---|
| Risk narrative generation | claude-sonnet-4-6 | Complex reasoning, long context |
| Form field extraction | claude-haiku-4-5 | Fast, cost-efficient for structured extraction |
| Coverage determination | claude-sonnet-4-6 | Legal reasoning required |
| Email classification | Workers AI (Llama 3) | Low latency, no external API call |
Invoking Agents via API
Section titled “Invoking Agents via API”Internal services invoke agents through the /internal/ prefix, which is auth-gated by API_SECRET:
POST /internal/agents/submissionAuthorization: Bearer <API_SECRET>Content-Type: application/json
{ "submissionId": "sub_01J8...", "action": "generate_narrative"}The MCP server (/mcp) exposes agent capabilities to external Claude integrations — see MCP Server for details.