Skip to main content
Back to all articles
AI Engineering 6 min readUpdated August 31, 2026

Human Approval Should Freeze the Exact Action, Not Pause the Conversation

A safe approval flow stores the exact proposed action, normalized arguments, authorization context, and idempotency key before pausing. On resume, it revalidates freshness and executes only what the reviewer actually approved.

By Salman Butt · Senior Full-Stack & Generative AI Engineer
#ai-agents#human-in-the-loop#approval-workflows#security#durable-execution#idempotency#typescript#python
On this page

“Ask the user before doing anything dangerous” sounds like a good agent policy until you try to make it reliable.

A model proposes a production configuration change. The UI asks for approval. Ten minutes later the user clicks Approve. Meanwhile the underlying resource changed, the model context was compacted, the worker restarted, or the agent reformulated the tool arguments.

What exactly was approved?

If the answer is “whatever the agent is about to do now,” the approval was mostly theater.

I prefer to treat human approval as a durable authorization-like artifact tied to one concrete proposed action. The workflow persists that action before it pauses. The reviewer sees the important fields. On resume, the executor verifies that the arguments still match, that the actor is still authorized, and that relevant resource state has not invalidated the decision.

The example here is a deployment assistant that may change a production service's image and replica count.

Approval begins with a normalized proposal

The model can reason in natural language, but the approval boundary should be structured.

TypeScript
type DeploymentChange = {  serviceId: string;  environment: "staging" | "production";  image: string;  replicas: number;  expectedResourceVersion: string;};​type ProposedAction = {  action: "deployment.update";  arguments: DeploymentChange;  idempotencyKey: string;};

The application validates this object before it ever reaches a reviewer:

TypeScript
function validateProposal(proposal: ProposedAction): void {  if (proposal.arguments.replicas < 1 || proposal.arguments.replicas > 50) {    throw new Error("Replica count is outside the allowed range");  }​  if (!proposal.arguments.image.includes("@sha256:")) {    throw new Error("Production image must be pinned by digest");  }}

Human approval is not a substitute for schema and policy validation. I do not want a person reviewing malformed arguments that application code already knows are impossible.

Hash the action that was shown

A reviewer should approve a stable representation.

TypeScript
import { createHash } from "node:crypto";​function actionHash(action: ProposedAction): string {  const canonical = JSON.stringify({    action: action.action,    arguments: {      ...action.arguments,      // Explicit field order for this contract.      serviceId: action.arguments.serviceId,      environment: action.arguments.environment,      image: action.arguments.image,      replicas: action.arguments.replicas,      expectedResourceVersion: action.arguments.expectedResourceVersion,    },    idempotencyKey: action.idempotencyKey,  });​  return createHash("sha256").update(canonical).digest("hex");}

For a real generic platform I would use a stable canonicalization implementation rather than rely on ordinary object serialization. The key idea is that the stored hash represents the exact action under review.

The approval record can then be:

TypeScript
type ApprovalRequest = {  id: string;  runId: string;  tenantId: string;  requestedByUserId: string;  action: ProposedAction;  actionHash: string;  status: "pending" | "approved" | "rejected" | "expired";  expiresAt: string;  reviewedByUserId?: string;  reviewedAt?: string;};

This is durable application state, not a message buried in conversation history.

Approval UI should show consequences, not raw JSON alone

The stored action can be JSON. The review experience should translate it into the fields a person needs to make a decision.

For a deployment:

Text
Service: checkout-apiEnvironment: productionImage: registry.example/checkout@sha256:…91e2Replicas: 6 → 10Current resource version when proposed: 1842Requested by: Salman

I also want the UI to distinguish what the agent inferred from what the application fetched directly. The current replica count, for example, should come from trusted resource state rather than a prose explanation written by the model.

For a refund, the important fields would be amount, currency, payment/customer, reason, and whether a previous refund exists.

Approval is a product surface as much as a backend state.

Pause durably

After the request is persisted, the worker should be free to stop.

TypeScript
async function requestApproval(  run: AgentRun,  proposal: ProposedAction,): Promise<ApprovalRequest> {  validateProposal(proposal);​  const request = await approvalRepo.create({    runId: run.id,    tenantId: run.tenantId,    requestedByUserId: run.userId,    action: proposal,    actionHash: actionHash(proposal),    status: "pending",    expiresAt: new Date(Date.now() + 24 * 60 * 60 * 1_000).toISOString(),  });​  await runRepo.markWaitingForApproval(run.id, request.id);  return request;}

There is no await waitForHumanForever() call holding one application request open.

When the reviewer responds, an event wakes the durable run.

Revalidate before execution

Approval says that a person accepted a specific proposed action. It does not prove the world stayed unchanged while the run was paused.

Before executing, I re-check several invariants:

TypeScript
async function validateApprovedAction(  approval: ApprovalRequest,  actor: ActorContext,): Promise<void> {  if (approval.status !== "approved") {    throw new Error("Action has not been approved");  }​  if (Date.parse(approval.expiresAt) <= Date.now()) {    throw new Error("Approval has expired");  }​  if (actionHash(approval.action) !== approval.actionHash) {    throw new Error("Approved action was modified");  }​  await authorizeDeploymentUpdate(actor, approval.action.arguments.serviceId);​  const current = await deploymentRepo.get(    approval.action.arguments.serviceId,  );​  if (    current.resourceVersion !==    approval.action.arguments.expectedResourceVersion  ) {    throw new Error("Deployment changed after approval was requested");  }}

A resource-version mismatch does not automatically mean the action is unsafe. It means the old approval no longer matches the state it was based on.

The workflow can refresh, replan, and request a new approval if necessary.

Do not let the model edit an approved action

This is a subtle workflow bug:

  1. reviewer approves replicas=10;
  2. agent resumes and decides replicas=12 would be better;
  3. executor runs 12 using the old approval.

The approved object should be immutable. If arguments change materially, create a new proposal and approval request.

That includes destination fields, amounts, resource IDs, permission changes, and other security-relevant values.

A model can change its mind. The approval cannot quietly change with it.

Python model

Python
from dataclasses import dataclassfrom datetime import UTC, datetimefrom enum import Enum​class ApprovalStatus(str, Enum):    PENDING = "pending"    APPROVED = "approved"    REJECTED = "rejected"    EXPIRED = "expired"​@dataclass(frozen=True)class DeploymentChange:    service_id: str    environment: str    image: str    replicas: int    expected_resource_version: str​@dataclass(frozen=True)class ApprovalRequest:    id: str    run_id: str    tenant_id: str    action_hash: str    change: DeploymentChange    idempotency_key: str    status: ApprovalStatus    expires_at: datetime​​def ensure_approval_live(approval: ApprovalRequest) -> None:    if approval.status is not ApprovalStatus.APPROVED:        raise PermissionError("Action is not approved")​    if approval.expires_at <= datetime.now(UTC):        raise PermissionError("Approval has expired")

The remaining checks—authorization, action hash, and resource version—belong in the execution service because they require current application state.

Approval should carry the reviewer identity

For sensitive actions, “approved=true” is not enough for auditability.

I store:

  • reviewer user ID;
  • review timestamp;
  • role or permission snapshot/policy version;
  • optional review comment;
  • action hash;
  • run ID;
  • final execution result.

If two-person approval is required for a class of operations, model it as a policy over approval records rather than asking the agent to count “yes” messages in chat.

Authorization happens before and after the pause

I normally authorize the proposal before showing it. That avoids sending a reviewer an action the requesting actor had no right to initiate.

I also authorize again at execution time.

Permissions can change while approval is pending. An employee can lose access. A tenant subscription can change. A resource can move to another ownership scope.

A day-old approval should not resurrect permissions that no longer exist.

Approval and authorization are separate gates with different lifecycles.

Use risk policies to decide what requires approval

Do not make the LLM decide whether its own action is “risky enough.”

A deterministic policy is easier to review:

TypeScript
type ActionRisk = "low" | "medium" | "high";​function approvalRequired(input: {  action: string;  environment?: string;  amountCents?: number;}): boolean {  if (input.action === "deployment.update" && input.environment === "production") {    return true;  }​  if (input.action === "refund.create" && (input.amountCents ?? 0) > 10_000) {    return true;  }​  return false;}

Thresholds here are illustrative. A real product should derive them from business policy, not copy them from an example article.

Low-risk reads should not become approval fatigue

If every tool call prompts a user, people learn to approve without reading.

I reserve mandatory approval for actions whose consequences justify interruption: money movement, production changes, deletion, external communication, permission changes, publishing, or other domain-specific risks.

Read-only inspection can often run without a confirmation prompt after authentication and authorization.

Good safety UX is selective. Friction that appears everywhere becomes invisible.

Batch approval needs bounded scope

Sometimes an agent wants to perform twenty similar operations, such as creating issues for twenty confirmed failures.

The reviewer may approve the batch, but the grant should still define boundaries:

TypeScript
type BatchApprovalGrant = {  tool: "issue.create";  projectId: string;  maxCalls: number;  allowedPriorities: Array<"low" | "medium" | "high">;  expiresAt: string;};

The executor checks each generated call against the grant.

Approving “this batch” should not become an unlimited write capability for the rest of the run.

Rejection should become workflow state, not an error to retry

If the reviewer rejects a proposed refund, the agent should not reinterpret rejection as a transient tool failure and ask again with slightly different wording.

The workflow can:

  • stop and report rejection;
  • accept a reviewer comment and replan if the product allows it;
  • ask the user for a different instruction.

But automatic retry of a human rejection is generally the opposite of human-in-the-loop control.

Approval is also useful for uncertain side effects

Even when policy does not require it, a confidence or ambiguity gate can escalate a case.

For example, a support agent may normally draft and send standard replies automatically, but route a response to a reviewer when:

  • detected account identity is ambiguous;
  • required source evidence is weak;
  • the reply contains a compensation offer;
  • the destination address differs from account records.

Those conditions should be measurable and as deterministic as practical. “The model feels unsure” is not a sufficient policy by itself unless the uncertainty signal has been calibrated.

Test the pause boundary

Important tests include:

  • worker restarts while approval is pending;
  • approved action arguments cannot be mutated;
  • resource version changes before execution;
  • requester loses permission after approval;
  • approval expires;
  • duplicate approval events arrive;
  • duplicate resume jobs arrive;
  • a rejected action is not retried automatically;
  • idempotency prevents double execution after an approved write times out.

The most useful test asks what can happen *between* proposal and execution, not only whether the UI has an Approve button.

When approval is unnecessary

A private research assistant that only reads public documents probably does not need a workflow approval subsystem.

Approval becomes important when an agent crosses from analysis into consequential action.

At that boundary, the safest mental model is not “pause and ask the user.” It is “create a durable, immutable proposal and require a human authorization event for that exact proposal.”

That small change in wording leads to much stronger architecture. The conversation can evolve; the worker can restart; the world can change. The action that was approved remains precise and auditable.

KEEP READING

Related engineering notes