Back to Blog Home

Human-in-the-Loop Approval for AI Agent Workflows in Slack

Page comment thread where a teammate is asked to review and clarify part of a document

Treat an Approve click as a vote on one stored proposal, not as permission. The proposal is the exact tool call, arguments and destination, saved on your server before the Slack card is posted. The click decides only whether that record runs now, once, under the requester's own current permissions. If the system cannot show which paused call a click belongs to, who was allowed to decide, whether the arguments changed and whether the action ran once, an approval workflow adds risk instead of removing it.

Decide which actions need a person

Do not route every agent step through a person. That recreates the manual queue and teaches reviewers to approve without reading. Slack's agent design guidance makes both halves of the point: require explicit confirmation, with a preview, for actions with real-world implications such as creating, sending or deleting content, and do not ask on every action, because that trains people to click through without reading. Classify actions by their effect and reversibility.

Start with three policy classes:

  1. Read automatically: search permitted knowledge, inspect a repository, fetch analytics, or summarize opened evidence when the operation does not change an external system.
  2. Prepare, then review: draft a knowledge update, support response, pull request, report, or customer communication. The agent may assemble evidence, but a person decides whether to continue.
  3. Block, or require stricter approval: destructive code changes, permission changes, customer-visible sends, financial commitments, bulk edits, or actions whose destination cannot be verified.

Kipwise Agent provides the product context for this boundary. Work continues in a Slack thread, connected sources can be searched, knowledge can be written, GitHub can be accessed with safeguards, and consequential actions stay explicit. The approval policy should apply to the proposed effect, not merely to the name of the tool.

Reading a GitHub file can be automatic. Preparing a patch may be reviewable. Merging it or changing repository permissions needs a stricter rule. The same connector can therefore contain actions from all three classes.

Assign every rule an owner, reviewer group, maximum age, editable fields, and fallback behavior. If the policy engine cannot classify a proposed action, fail closed and show the missing classification to the admin.

Store the approval before you post the card

A production approval can outlive the worker that requested it. It may wait through a deployment, a reviewer handoff, or a Slack retry, so in-memory state is not enough. The OpenAI Agents SDK human-in-the-loop guide documents the execution model: a run pauses before a sensitive tool call, its state is serialized, a person approves or rejects, and the original run resumes. The LangChain human-in-the-loop guide uses persistent checkpointing the same way and supports approve, edit, reject, and respond decisions.

The record also has to outlive the Slack message, not only the process that created it. Slack retention settings can delete messages, the Free plan shows only the last 90 days of history, and people can edit what they posted. A decision that exists only in the thread may be gone, or different, when an auditor asks. Keep the approval record in your own store and post a receipt in the thread that links to it.

Persist the record before posting the card. One workable schema looks like this:

approval_id: apr_01HITL
run_id: run_01WORK
state: pending
requester:
 slack_user_id: U_REQUESTER
 workspace_id: T_WORKSPACE
thread:
 channel_id: C_OPERATIONS
 thread_ts: "1789412400.001200"
proposal:
 tool: github.create_pull_request
 destination: org/repository
 arguments_digest: sha256:PROPOSAL_DIGEST
 evidence_record_ids:
 - ev_01SOURCE
policy:
 risk_class: consequential-write
 reviewer_group: engineering-maintainers
 editable_fields:
 - title
 - body
 expires_at: "2026-09-14T18:00:00Z"
decision:
 status: pending
 decided_by: null
 decided_at: null
execution:
 status: not_started
 attempt_id: null
delivery:
 status: not_attempted
 slack_message_ts: null

This is an implementation recommendation, not a vendor schema. Keep sensitive source material out of the record when identifiers and evidence links are enough.

Bind the approval to a server-issued pause

Bind every approval to a paused tool call your server issued, not to action data rebuilt from a client message. An open Pydantic AI issue about approval provenance describes the risk: when an agent served over a UI adapter resumes after approval, the framework decides whether to run the tool from data the client sends back, and nothing on the server proves the approved call came from a real paused run. Its author notes that the documented trust boundary already covers this and presents the change as optional hardening, not a vulnerability.

For a Slack workflow, use this sequence:

  1. Create the exact proposed tool call on the server.
  2. Persist its run ID, tool name, normalized arguments, destination, policy version, and digest.
  3. Issue a random, single-purpose approval ID that refers to that record.
  4. Put only that opaque approval ID in the Slack interaction value.
  5. On interaction, load the server record and compare its stored digest.
  6. Reject the decision if the record is missing, expired, already consumed, or no longer matches the paused run.

Do not trust the Slack message body as the source of truth. Clients can replay payloads, and formatting can omit fields. The message explains the request. The server record defines it. Most examples begin with a valid in-process tool call, so the second boundary, between the paused run and the reviewer interface, is the one to test explicitly.

Show enough context for a real decision

An approval card should let the reviewer decide without opening five systems, but it should not copy every sensitive input into Slack.

Show:

  • the requesting person and originating thread;
  • the proposed action and exact destination;
  • a concise summary of arguments that will affect the result;
  • links to permitted source evidence;
  • the reason approval is required;
  • fields the reviewer may edit;
  • the expiry time and policy owner;
  • Approve, Reject, and Request changes actions.

The Slack interactivity guide covers interaction payloads, response URLs, acknowledgements, and ways to publish responses back to Slack. Acknowledge the click quickly, then update the original thread after the server has validated and recorded the decision.

A button click should first move the record from pending to approved or rejected. It should not make the external write inside the acknowledgement handler. A separate worker can claim the approved record, recheck authorization, and perform the tool call. This separation keeps Slack retries from becoming action retries.

Allow edits only where the policy names them. If a support lead may edit response text but not the customer or channel, enforce that server-side. Recalculate the proposal digest after an allowed edit and preserve both versions. A change to the destination, repository, access scope, or action type should usually create a new approval.

Approval does not widen authority

A reviewer's click decides whether the action goes now. It must not widen what the action may do. The action runs with the requester's own permissions, rechecked at execution, so a reviewer with more access than the requester never becomes a way around the requester's limits. The same Slack guidance sets this limit for reads: an agent should not use information the invoking user could not access on their own. We apply it to writes too. An approval records intent, not permanent permission.

The requester or reviewer may lose access while a decision is waiting. A channel can become private, a repository role can change, a support ticket can move to another account, or the underlying object can be deleted. An approval made under yesterday's permissions must not bypass today's controls.

At execution time, verify:

  • the requesting Slack identity still maps to the expected product identity;
  • the reviewer still belongs to the required approval group;
  • both identities belong to the expected workspace and tenant;
  • the requester still has permission for the proposed action where applicable;
  • the destination still exists and matches the stored identifier;
  • the proposal has not expired or changed;
  • the policy version still permits the action.

If a check fails, keep the proposal unexecuted and post a specific reason to the original thread. Do not silently ask a different identity, such as a broad service account, to complete an action the requester can no longer perform. If the product intentionally uses delegated service authority, show that fact in the approval card and policy record.

Consume each decision once and separate the outcomes

Track approval, execution, and delivery as separate states, and consume each approval decision only once.

A LangGraph proposal for a production approval example lists the gaps in the stock interrupt pattern: in-memory approval state that dies with a worker restart, no Slack or email bridge, duplicate resume calls that both succeed, no audit trail, and no multi-user routing. It names an open-source approval service as its example, so read it as a gap list rather than a neutral survey. The failure it describes is still worth testing: the same decision can arrive more than once.

Use an atomic state transition when a worker claims an approved action:

if approval.state != "approved":
 stop("approval is not executable")

changed = compare_and_set(
 approval_id,
 from_state="approved",
 to_state="executing",
 attempt_id=new_attempt_id
)

if not changed:
 stop("approval was already consumed")

recheck_authorization()
execute_bound_tool_call()
record_execution_result()
publish_thread_receipt()
record_delivery_result()

The compare-and-set operation ensures that two workers cannot consume the same approval. The external tool should also receive an idempotency key where supported. If the worker crashes after sending the request but before recording the result, reconcile by that key or by querying the destination. Do not start another write merely because the local status is uncertain.

Keep these states distinct:

approval: pending | approved | rejected | expired | cancelled
execution: not_started | executing | succeeded | failed | unknown
receipt: not_attempted | posting | delivered | failed | unknown

An approved action has not necessarily executed. A successful execution has not necessarily produced a visible Slack receipt. This distinction gives admins an accurate queue of uncertain outcomes instead of one green status that hides a failed write or failed notification.

A code-change example

An engineer asks the agent in Slack to update a configuration file and open a pull request. The agent reads the permitted repository and relevant internal runbook, prepares a patch, and pauses before the GitHub write.

The approval card names the repository, base branch, files changed, patch digest, pull-request title, source links, requester, expiry, and required reviewer group. A maintainer approves in the same thread.

Before execution, the worker reloads the server-issued proposal. It confirms that the approval ID belongs to the paused run, the digest still matches, the maintainer remains authorized, the requester can still access the repository, and the base branch is current. It atomically changes the approval state to executing, then opens one pull request with the stored idempotency key.

If GitHub confirms the pull request but the Slack update times out, execution is succeeded and receipt delivery is unknown. The worker checks the thread before reposting. It does not open another pull request. The final receipt links to the pull request, records who approved it, and states that the proposed patch digest was the one executed.

If the base branch or destination changed, the old approval expires. The agent recalculates the patch and asks for a new decision. It does not treat approval of the earlier proposal as consent for a materially different action.

Handle rejection, expiry, and recovery

Rejection is a terminal decision with an optional reason. Request changes creates a revised proposal and a new digest. Cancellation by the requester invalidates any pending card.

  • If Slack sends the same interaction twice, return the recorded decision without consuming it again.
  • If the worker restarts, reload pending and executing records from durable storage.
  • If execution times out, mark it unknown and reconcile the destination before retrying.
  • If authorization changes, leave the action unexecuted and explain the failed check.
  • If the proposal expires, disable or replace the interactive controls and state that a new proposal is required.
  • If receipt delivery fails, retry only the receipt, not the consequential action.
  • If evidence becomes unavailable, stop and ask the requester to refresh the proposal.

Log policy decisions and state transitions, but redact source bodies, credentials, customer data, and unrestricted tool arguments. An audit trail should prove what was proposed and decided without becoming another sensitive data store.

Tests to run before enabling writes

Run these in a non-production workspace before enabling consequential writes:

  1. Alter the client-visible action data and confirm the server ignores it.
  2. Replay an approval payload, then deliver two approvals at once, and confirm the action executes once.
  3. Restart the worker while an approval is pending and confirm the run can resume.
  4. Remove the reviewer's role, then the requester's destination permission, after approval. Confirm execution is blocked and service authority does not bypass policy.
  5. Edit an allowed field and confirm the revised digest and prior value are kept. Change a protected field and confirm a new approval is required.
  6. Let the record expire and confirm the old button cannot resume the run.
  7. Time out the external write and confirm reconciliation comes before any retry. Fail the Slack receipt and confirm the external action is not repeated.
  8. Confirm the final thread message distinguishes approved, executed, and delivered, and that the logs hold identifiers without sensitive payloads.

Track median approval latency, expired proposals, rejected actions, changed proposals, replay attempts blocked, permission changes caught, unknown execution outcomes, duplicate actions, and missing receipts. These measures expose control failures and review friction without treating approval volume as success.

Choose one reversible Slack agent write, define its server-side proposal record and state machine, and run the replay, permission-change, and uncertain-delivery tests before expanding the policy to customer-visible or destructive actions.

Topics

Related posts

Your team’s knowledge, answered in Slack

Add the Kipwise Agent. It answers from your pages with the source, and asks before it changes anything. 7-day trial, no card needed.