Human-in-the-Loop Agents: Designing Useful Approval Gates
Design human-in-the-loop agent approvals with immutable proposals, qualified reviewers, expiry, durable resumption, and checks against changed resource state.
Abhishek Raj · · 8 min read
Prepared with AI research assistance. Sources are linked throughout; worked examples are illustrative unless stated otherwise. Editorial approach.
A useful human-in-the-loop approval gate answers a precise question: may this actor execute this specific action against this resource under these conditions? A generic “Continue?” button answers much less. It can record agreement while leaving the actual tool arguments, authorization scope, and execution time ambiguous.
Approval is part of the workflow’s state and authority model. It needs a durable proposal, a qualified reviewer, an explicit decision, and enforcement immediately before execution. The architecture below is an illustrative design for an agent that proposes account changes; it is not a tested implementation or a compliance certification.
Choose the boundary that needs judgment
Start with the consequence of an action. Reading a permitted knowledge article and disabling a customer account should not automatically share the same review policy. In this proposed design, ordinary authorized reads proceed, while consequential mutations require a gate defined by application policy.
A model may recommend escalation, but it should not be the sole authority deciding whether its own operation requires approval. Otherwise the component proposing an action also determines which controls apply. Implement the final policy in trusted application code, using authenticated identity, resource class, operation, and business conditions.
Define what the human contributes. A reviewer might judge whether evidence justifies an account suspension, verify a recipient before an external message, or choose among business alternatives. If the answer can be computed from an established rule, enforce that rule directly. Repeatedly asking people to confirm deterministic checks consumes attention without necessarily adding judgment.
Also distinguish user clarification from authorization. Asking which account a person meant resolves an input. It does not establish that the person may suspend that account. Record these as separate interactions.
Bind the decision to an immutable proposal
OWASP’s transaction authorization guidance recommends showing significant transaction data, enforcing authorization server-side, protecting transaction details against modification, and checking authorization at execution. Although its examples focus on transactions, those principles provide a useful foundation for agent action approval. OWASP Transaction Authorization Cheat Sheet.
For the illustrative account workflow, persist a proposal such as:
{
"approval_id": "apr_87",
"proposal_revision": 3,
"run_id": "run_21",
"tenant_id": "tenant_8",
"operation": "suspend_account",
"arguments": {"account_id": "acct_42", "reason_code": "verified_abuse"},
"resource_version": 12,
"evidence_refs": ["case_19@v5"],
"policy_version": "suspension-v4",
"expires_at": "2026-11-10T12:30:00Z",
"status": "PENDING"
}
All identifiers and timestamps are fictional. The server supplies tenant identity and policy context. An agent-generated tenant field is not an authorization credential.
Create a canonical action representation and bind the approval record to it, for example with a digest over the versioned operation envelope. A digest detects changes relative to the stored proposal; it does not prove who approved, protect a compromised server, or replace access control. Keep the authoritative envelope server-side, and render the review interface from that envelope rather than from an independent model-written summary.
When the reviewer edits a material field, create a new proposal revision. If an edited recipient or amount changes the action, the old approval must not silently authorize the replacement. Track which policy-defined fields are material and test that classification.
Make the review screen useful
Show the exact target, scope, intended changes, source evidence, and expected consequence. For account suspension, display the account’s stable identifier alongside its recognizable name, the affected tenant, current status, and the proposed transition. A name alone is dangerous when multiple accounts have similar labels.
Keep model interpretation separate from source evidence. A sentence such as “likely fraudulent” is a recommendation; the underlying case records are evidence. Reviewers need to inspect both without confusing generated language with a confirmed fact.
Offer meaningful outcomes: approve this revision, reject with a reason, request missing evidence, or edit into a new proposal. Avoid a single confirmation control that also acts as a request for clarification. A rejection should produce a stable workflow outcome, not invite the agent to rephrase the same action until someone accepts it.
For batches, make the approved scope explicit. “Approve all” should identify a fixed set of proposal IDs and revisions. Adding an item to a mutable batch after approval must not inherit the existing decision.
Persist the wait and resume the correct run
LangGraph interrupts persist graph state through a checkpointer and resume using a thread identifier and a supplied command. Importantly, resumption restarts the containing node; code before the interrupt runs again. That makes side effects before the interruption a duplication hazard. LangGraph interrupt documentation.
In this design, separate proposal preparation, waiting, and execution into distinct steps. Persist the proposal before notifying the reviewer. Make notification delivery independently retryable, and deduplicate repeated notifications by approval ID. The approval service stores the decision before it asks the orchestrator to resume.
Temporal’s official human-in-the-loop recipe illustrates another mechanism: a Signal carries the decision, the workflow matches its request identifier, and a durable wait has a timeout. Its execution activity is a demonstration that logs actions; production side effects require additional contracts. Temporal human-in-the-loop recipe.
Neither framework makes an arbitrary resume request authorized. Authenticate the reviewer at the application endpoint, authorize access to the specific approval, validate its current state, and resolve the server-owned run reference. A client-supplied run ID should not be enough to resume another tenant’s workflow. See durable agent workflows for checkpoint and replay boundaries.
Treat expiry and changed state as distinct outcomes
An approval can become unsafe while waiting even though its payload remains unchanged. The account may have been restored by another operator, the evidence may have been corrected, or the reviewer may have lost the relevant role.
Choose expiry based on how quickly the decision’s assumptions can change. A fixed ten-minute limit is not inherently correct; some actions need much shorter validity, while others can tolerate longer review. The important requirement is an explicit, enforceable policy.
A proposed state machine can distinguish:
| Current state | Event | Result |
|---|---|---|
| PENDING | Authorized approval before expiry | APPROVED |
| PENDING | Rejection | REJECTED |
| PENDING | Expiry | EXPIRED |
| APPROVED | Preconditions still hold | EXECUTING |
| APPROVED | Relevant resource or policy changed | STALE |
| EXECUTING | Verified effect | COMPLETED |
| EXECUTING | Ambiguous remote result | RECONCILING |
Use server time for expiry. Record the accepted decision with its proposal revision and reviewer identity. If rejection and approval arrive concurrently, allow only one valid transition from PENDING and return the recorded outcome to the losing request. An expired request should not become approved merely because its notification remained open in a browser.
Close the check-to-action gap
Revalidating a resource and then issuing a separate mutation creates a time-of-check-to-time-of-use gap: the resource can change between those operations. The approval service must coordinate with the system that owns the affected state.
For a mutation entirely within one database, a short transaction can lock the relevant approval and resource records, verify versions and authority, and commit the permitted state change. PostgreSQL documents that SELECT FOR UPDATE prevents conflicting modifications to the selected rows until the transaction ends. It does not lock unrelated records or a remote service. PostgreSQL explicit locking.
Never hold that transaction open while a human reviews. Persist the wait without a lock; acquire protection only during the short execution boundary. Where the target is remote, use its conditional mutation or version-precondition interface when available. A local approval-row lock cannot make a remote account version stable.
Carry a stable action identity into execution. If a remote call times out after suspension succeeded, the workflow should reconcile by action identity or target state before retrying. Approval authorizes an operation; it does not solve duplicate delivery. Idempotency for agent actions covers that separate boundary.
Test authority, races, and reviewer workload
Build tests around sequences rather than only successful clicks:
- Change the proposed account after approval and verify execution refuses it.
- Remove the reviewer’s permission before execution and verify the chosen reauthorization policy.
- Deliver the same decision twice and ensure the stored outcome is stable.
- Race approval against expiry and against another reviewer’s rejection.
- Restart the worker while waiting and verify it resumes the original proposal.
- Change the resource version between review and execution.
- Lose the remote response after a successful action and verify reconciliation avoids a duplicate effect.
Observe approval age, stale-proposal frequency, evidence requests, post-approval changes, and cases where reviewers catch real errors. A high approval rate alone does not prove safety: it might describe accurate proposals or habitual confirmation. Sample completed reviews and inspect whether the interface exposed the information needed to decide.
If the queue grows faster than reviewers can assess it, reduce unnecessary gates, improve evidence presentation, or narrow the automation’s scope. Automatically approving overdue consequential actions simply converts staffing pressure into hidden authority.
Frequently asked questions
Should every tool call require approval?
No. Define gates from authority, consequence, and uncertainty. Keep ordinary permitted reads efficient while reserving attention for decisions that require human judgment. Deterministic business constraints still need enforcement even when a human approves.
Can one approval cover multiple actions?
Yes, if the grant specifies a bounded, immutable set or an explicit capability with limits. A general approval for a goal should not be interpreted as unlimited permission for whatever actions a model later invents.
Does approval mean an action must execute?
No. It permits execution subject to remaining checks. Expiry, revoked authority, stale evidence, changed resources, cancellation, or a failed precondition may legitimately prevent an approved action from running.
Source reference list
Related reading
- Durable AI Agent Workflows: Checkpoints, Replay, and Recovery
Design durable AI agent workflows with checkpoints, recorded decisions, safe retries, and recovery paths that handle crashes without duplicating actions.
- Idempotency for AI Agent Actions: Preventing Duplicate Side Effects
Prevent duplicate AI agent actions with stable intent identities, immutable request fingerprints, durable ledgers, and recovery for uncertain outcomes.
- AI Agent Audit Logs: Provenance, Privacy, and Action Accountability
Design AI agent audit logs with trustworthy event producers, action provenance, durable delivery, tamper evidence, privacy controls, and investigation checks.