Skip to content

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.


POST /v1/... or WebSocket
OrchestratorAgent (DO)
┌────┴──────────────────────────────────┐
│ │
▼ ▼
SubmissionAgent UnderwritingAgent ClaimAgent ...
│ │ │
▼ ▼ ▼
EmailIntakeAgent WorldIntelligence AdjudicationAgent

All agents share:

  • Model: Claude (claude-sonnet-4-6 for reasoning, claude-haiku-4-5 for fast extraction)
  • Observability: Langfuse for tracing every prompt, response, tool call, and latency
  • State: Durable Object SQLite for conversation history and task state

Durable ObjectPurpose
SubmissionAgentProcesses new business submissions end-to-end
PolicyAgentMid-term policy actions (endorsements, cancellations)
ClaimAgentClaims workflow automation and AI-assisted investigation
UnderwritingAgentRisk assessment, rate justification, referral drafting
AdjudicationAgentCoverage determination and denial letter drafting
BordereauxAgentAutomated bordereaux generation and carrier submission
ComplianceAgentRegulatory deadline tracking and filing automation
ProducerAgentProducer onboarding and licensing workflow
TelematicsAgentTelematics data ingestion and risk scoring
LossControlAgentLoss prevention recommendations
WorldIntelligenceAgentExternal risk data enrichment (weather, FMCSA, news)
EmailIntakeAgentShared mailbox parsing and routing
NotificationAgentIntelligent notification dispatch and scheduling
CollaborationAgentDeal Room real-time collaboration
AssemblyAgentDocument assembly and form population
OrchestratorAgentMulti-agent task coordination
OpenInsureMCPMCP server for external AI integrations
DealRoomDOWebSocket-backed carrier deal room

The SubmissionAgent handles the full intake-to-quote workflow when triggered by either the producer portal or the email ingest cron.

  1. EmailIntakeAgent receives a new message from Underwriting@mhcmga.com via Graph API 2. Classifies the email (new submission, renewal, endorsement request, general inquiry) 3. Extracts attachments and stores them in R2 4. Invokes AssemblyAgent to 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

For every new submission, UnderwritingAgent generates an AI risk narrative using Claude:

// Simplified — actual implementation in packages/agents
const 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 negative

The narrative is attached to the submission record and displayed in the Underwriting Workbench.


ClaimAgent provides AI assistance throughout the claims lifecycle:

FeatureDescription
Coverage determinationAnalyzes the policy form and loss facts, drafts a coverage opinion
Reserve estimationSuggests initial reserve based on loss type, jurisdiction, and injury severity
Fraud signal detectionFlags patterns from the loss description and claimant history
Settlement recommendationBenchmarks against comparable closed claims
Denial letter draftingGenerates state-compliant denial letters from coverage position

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

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.


Use caseModelReason
Risk narrative generationclaude-sonnet-4-6Complex reasoning, long context
Form field extractionclaude-haiku-4-5Fast, cost-efficient for structured extraction
Coverage determinationclaude-sonnet-4-6Legal reasoning required
Email classificationWorkers AI (Llama 3)Low latency, no external API call

Internal services invoke agents through the /internal/ prefix, which is auth-gated by API_SECRET:

Terminal window
POST /internal/agents/submission
Authorization: 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.