mentionable.dev

Slack Tool Approvals

Audience: operators of the Slack Connector (examples/slack-connector) and bridge operators who want Claude/Codex native tool permission requests decided from the Slack thread that started the work.

Status: implementation guide for issue #641. Off by default. The wire contract belongs to vicoop-bridge’s tool-approval v1 extension and its requester-approval companion. The connector-side parsing is described in a2a-tool-events-slack-guide.

What the user sees

  1. The agent’s native runtime asks for permission to run a tool. The bridge keeps the execution waiting and moves the A2A task to auth-required (final: false).
  2. A public card appears in the same thread. It shows the agent, the tool name, who started the request, and the expiry time, along with a Review request button. It never shows the tool arguments.
  3. Only the original requester can open the review. That is the Slack user, in the same workspace, whose message started this execution. It is not the first author of the thread. Other users who click get a private “only the person who started this request…” notice, and the card stays open for the requester.
  4. The private modal shows the exact, unmodified arguments. Large inputs are split across pages and never truncated. Allow once appears only on the last page. Deny is available on every page.
  5. After a decision, the card shows who decided and the outcome, and its button is removed. The original execution resumes. The Connector sends no new prompt and creates no new task, and the results appear in the same thread.

Expiry (the bridge deadline is ten minutes), cancellation, and decisions made in the bridge web console are reflected on the card. When Slack cannot confirm an outcome — for example the bridge drops a finished request, so its approval URL returns 404 after the execution moved on — the card says the request is no longer pending and its outcome could not be confirmed. It never claims “expired” or “no decision was made” unless the bridge itself reported that.

The AskUserQuestion input-required flow is separate and unchanged. A tool approval raised while the agent handles an AskUserQuestion answer belongs to the user who answered.

Authority model

Slack request signatures (verified by VercelReceiver) prove only that Slack sent a click. Approval authority is checked in two independent steps:

  1. Local check. The Connector looks up the click’s opaque key in the durable slack_tool_approvals row. The click’s workspace and user must match the row’s requester. Button values carry nothing else, and modal private_metadata is treated as a hint that every action re-verifies. A key replayed onto another channel or message is refused.

  2. Bridge check. The Connector mints an OAuth-federation a2a:task.read continuation token for the original task and requester subject (slack:<team>/<user>). It presents that token to the request’s requesterApprovalUrl (/agents/:agentId/approvals/:requestId). The bridge separately requires all of the following:

    • the agent owner opted in with requester_approvals_enabled (default false)
    • the exact grant is still active
    • the execution is live
    • the original principal and actor identity match

    A 401 or 404 means “not authorized”, and nothing is revealed.

The GET response must name the same request, task, bridge agent, tool, and execution as the stored row before any argument is shown or decided. Every review, page change, and decision repeats both checks; nothing is cached.

The owner decisionUrl (/admin-api/...) is never used, and there is no owner-token fallback.

Endpoint pinning

MENTIONABLE_TOOL_APPROVAL_TRUSTED_ORIGINS lists the bridge origins the operator trusts, as https://host[:port] separated by commas. The requesterApprovalUrl must satisfy all of these rules:

Requests are sent with redirect: 'manual', and any 3xx response is refused. Persisted endpoints are re-validated against the current trust list on every use. A request that fails any of these rules gets an argument-free card that says the agent owner can decide in the bridge web console.

Rendering safety

The agent address, tool name, arguments, and bridge principal are agent-controlled or bridge-controlled. They are rendered only as plain_text or inside rich_text_preformatted text elements. They are never rendered as mrkdwn, and fallback text is escaped. Arguments never appear in public messages, logs, button values, or private_metadata. Allow requires the reviewed input digest and the last page. If the bridge input differs at decision time, the decision is refused.

Trace privacy. Native tool traces can carry the same arguments the approval keeps private, and they may stream before the first approval event. For an approval-capable execution — the Agent Card advertised (and the Connector activated) the tool-approval extension, the A2A endpoint is a configured trusted approval bridge, or an approval event was already seen — every public rendering keeps a tool call’s name, timing and failure status only: arguments and outputs are hidden, traceability-artifact text (such as the Bash: <args> fallback line or stdout) is dropped, and text-encoded tool calls are shown without arguments. This covers the live stream, single-shot replies and recovered results; AskUserQuestion keeps its question. The bridge additionally sanitizes native traces for remote-approval executions (PR #546); this connector-side redaction is defense in depth, not a replacement.

Durability and results

The Postgres table slack_tool_approvals stores the request-to-thread binding (approval_key, request, bridge origin and pinned URL, A2A endpoint, task, execution id, workspace, requester, channel, thread, placeholder, card, state, delivery). It does not store the tool input; the modal fetches the input fresh. Every transition is a single conditional UPDATE … RETURNING. Task-scoped operations (delivery, supersede) are keyed by workspace + A2A endpoint (bridge origin and agent) + task id + execution id, so identical task ids on different agents or executions never affect each other.

Slack writes and delivery uncertainty. The Connector does not rely on any Slack-side deduplication for chat.postMessage (there is no documented idempotency contract it could use), and a request can be accepted by Slack while its response is lost, or be delivered arbitrarily late after a process pause. Exactly-once delivery is therefore not achievable here. What the Connector does guarantee is an application retry guarantee: none of its own retry or recovery paths (reconciler runs, reclaimed leases, restarts, post-decision polling) ever starts a second POST for a logical message once a POST for it may have been sent. The remaining external ambiguity is reported as a gap, never hidden:

Gaps and manual recovery. If a process dies after the CAS but before Slack accepted the request, or the request is lost, the entry stays uncertain with no marked message. The card then never appears (the agent owner can still decide in the bridge web console), or the result is never reported as delivered: delivery stays pending, the reconciler keeps looking for the marked message, and two hours after the approval deadline it posts a “could not be retrieved or delivered” notice to the thread. Uncertain entries are logged with their key as “message uncertain and not found” (keys: card:<approval_key> or result:<scope-hash>:<index>).

There is no automatic or safe self-service re-post. Seeing that the message is missing from the thread is not sufficient: a paused or in-flight old request can still be accepted by Slack later. Releasing an uncertain entry (deleting its ledger row) is a manual, duplicate-risk operator override and should only be done when the operator has verified that no process that could still hold the original request is running (for example, every function instance / worker from before the incident has been stopped or redeployed and its HTTP requests can no longer complete), and accepts that a duplicate is still possible if that verification is wrong. Otherwise, leave the entry uncertain and point users to the agent reply or the bridge console.

Card renders are fenced by a per-card render generation claimed (and recorded as in flight) before each Slack write. Only the latest render that Slack accepted may mark the card as showing the current state, and only if no older render finished after it started, no older render is still in flight, and the state is unchanged. A render that finishes after a newer one started (Slack may display it last), whose update threw or timed out (it may still apply), or whose process died before recording its outcome leaves the card dirty, and the reconciler re-renders the latest state, so a delayed stale update racing a decision converges to the decided card. An in-flight render that can never be confirmed (crash, lost DB write, unknown outcome) keeps the card conservatively dirty: the reconciler keeps re-rendering the current state on each run until the 24 h reconcile horizon, which costs repeated chat.update calls but never leaves a stale card recorded as current.

Results. Once an approval card is bound on a live stream, the rest of the reply is not streamed piecemeal. At the final frame the result is posted as marked messages — the reply (text after the card; text before the card stays in the placeholder) and every AskUserQuestion not already shown — and marked delivered only after Slack accepted all of them (ok: true each). A question already posted before the card is not repeated, and questions that appear after the card are rendered only by this final delivery. If any post fails it is handed to the reconciler. A single-shot or async message/send that returns a Task already waiting on an approval is bound the same way (detached; no empty reply, and no push-callback registration).

When the stream ends early (idle or max timeout, the serverless maxDuration cut-off, a disconnect), the turn is not reported as an error: delivery is marked detached.

The reconciler (/api/cron/reconcile-tool-approvals, plus bounded polling right after a Slack decision) claims rows with a lease and FOR UPDATE SKIP LOCKED. For each row it:

Setup

All of the following are required. If any is missing, the feature stays off and threads get the argument-free notice instead.

RequirementNotes
Bridge with tool approvalsvicoop-bridge with PR #545 (tool-approval v1) and PR #546 (requester approvals): requesterApprovalUrl + executionId in the request metadata, Task.metadata[URI].executionId on tasks/get, the requester GET/POST accepting the task.read continuation token.
Agent owner opt-inrequester_approvals_enabled on the bridge agent (default false).
Runtime opt-inremote_approvals / approval_decision: "remote" in the bridge client config (see tool-approval v1).
MENTIONABLE_TOOL_APPROVAL_TRUSTED_ORIGINSComma-separated bridge origins, e.g. https://bridge.example.com.
POSTGRES_URLDurable store; slack_tool_approvals is created on first use. There is no in-memory fallback.
OAuth federationMENTIONABLE_ADAPTER_SIGNING_KEY_JSON and a public host, as for #621. The continuation token is the requester’s bridge-verifiable identity.
Reconcile scheduler (~every minute)CRON_SECRET plus something calling /api/cron/reconcile-tool-approvals about once a minute (see below).
Slack scopesThe default scopes (channels:history, groups:history) let retries find already-posted cards/results by metadata.

Scheduler. The default vercel.json runs the reconcile route once a day, which keeps Deploy-to-Vercel on the Hobby plan working (it only cleans up old rows when approvals are off). An approval-enabled deployment must call it about every minute, because results of executions that outlive the Slack function are delivered by it:

Overlapping runs are safe (row leases). The live stream and the bounded post-decision polling still deliver many results without the scheduler, but not all.

Limits and follow-ups