Skip to main content
HS
HiSETSuccess
LeetCode Prep

AI & FDE Interview Room

Role paths, mocks, cost studio, chapters, cases, and staff-level depth.

Case study · Architect · 40 min

Agentic Workflow with Human Approval Gates

Orchestrate a multi-step business agent that drafts actions, pauses for human approval on irreversible steps, then resumes reliably.

agentsHITLworkflows

Interview opener

Agent proposes actions that need human approval in enterprise.

  1. 1.How do you represent pending actions durably?
  2. 2.Approver is offline — timeout policy?
  3. 3.Audit trail for regulators?

Strong signals

Hit 0/3

Weak signals (avoid)

  • Fire tools then ask forgiveness
  • No durable state for approvals

Requirements

  • Workflow: intake → research → draft email/CRM update → approve → execute
  • Human SLA: approvals within 4 business hours; reminders at 2h
  • Idempotent execution; full audit; resume after deploy
  • Scale: 2,000 workflows/day; 30% need approval

Back-of-envelope Estimation

MetricCalculationResult
Workflows/day2,0002,000
LLM calls/workflow~510,000
Tokens/day10K × 2.5K25M (~$50)
Approvals/day0.3 × 2,000600
Approver load600 × 2 min20 hours
Queue storagestate machines × 30dmodest

API Design

EndpointMethodDescription
POST /v1/workflowsPOSTStart workflow with input payload
GET /v1/workflows/{id}GETState, history, pending approval
POST /v1/approvals/{id}/decidePOST{ approve|reject|edit, notes }
POST /v1/workflows/{id}/resumePOSTInternal worker resume after approval

Data Model

EntityKey fieldsNotes
workflowsid, type, state, cursor, tenant_idDurable state machine
stepsworkflow_id, name, input, output, statusAppend-only log
approvalsid, workflow_id, reviewer, decisionBlocks execute step
outboxevent_id, payload, sentReliable side effects

High-level Design

Durable agent loop
API → Workflow engine (Temporal-like)
         ├ step: research (LLM + tools) → save artifacts
         ├ step: draft (LLM) → create approval record
         ├ WAIT human decision (timer + reminders)
         ├ step: execute tools via outbox (idempotent keys)
         └ step: notify requester

Crash/deploy: resume from cursor; never re-send without idempotency

Deep Dive: Approval UX & Safety

  • Show diff of proposed CRM fields and email body with sources
  • Allow edit-then-approve; treat edits as new model-visible feedback
  • Separate draft identity from execute identity (least privilege)
  • Timeouts: auto-escalate to secondary approver, never auto-approve irreversible actions

Bottlenecks at Scale

  • Approver bottlenecks — load-balance queues by skill
  • Long-running waits — durable timers, not thread sleeps
  • Duplicate executes on retry — outbox + idempotency keys mandatory

Failure Modes & Monitoring

SLOTargetAlert
Approval SLA< 4 business hRemind + escalate
Duplicate side effects0Page
Workflow success> 95%Warn
Stuck in WAIT< 2% > 24hSweep job

Attempt the case aloud first. Then unlock a staff model answer outline.