Aaron Diemel
Back to work
2026

Agentic Audit Platform

Durable Execution Environment

Durable AgentsTool CallingHuman-in-the-LoopWorkflow Orchestration

Overview

A reference architecture for AI-native audit execution—a durable substrate where agents ingest documents, reason over structured engagement state, call tools, request missing inputs, and pause/resume across long-running workflows with explicit human control points. Transforms auditing from human-scale document workflow into machine-scale procedural execution.

Challenges

  • Audits span weeks with complex document dependencies and approval gates
  • Existing tools lack durable state management for long-running agent workflows
  • Human oversight required at critical decision points without breaking execution flow
  • Document ingestion requires structured extraction across varied formats

Approach

  • Built execution graph architecture with persistent state checkpointing
  • Implemented tool schema with Zod for structured document extraction
  • Created human approval gates that pause/resume without losing context
  • Designed MCP server integration for external system orchestration

Durable Agent State Management

typescript
// Checkpoint-based execution with human approval gates
interface AuditState {
  engagementId: string
  documents: ProcessedDocument[]
  findings: Finding[]
  pendingApprovals: ApprovalRequest[]
  checkpointId: string
}

async function executeAuditStep(state: AuditState) {
  const checkpoint = await loadCheckpoint(state.checkpointId)
  
  // Resume from last known state
  const agent = createAgent({
    model: "claude-sonnet-4-20250514",
    tools: [extractDocument, analyzeFinding, requestApproval],
    state: checkpoint
  })

  const result = await agent.run({
    onApprovalRequired: async (request) => {
      // Persist state and pause for human review
      await saveCheckpoint({ ...state, pendingApprovals: [request] })
      return { status: "paused", resumeToken: request.id }
    }
  })

  return result
}

Tech Stack

TypeScriptVercel AI SDKSupabaseZodMCP ServersClaude Agent SDK

Outcomes

  • Reduced manual document processing time by 80%
  • Achieved reliable pause/resume across multi-day workflows
  • Enabled non-technical auditors to interact with agent via natural language