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
- 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). - 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.
- 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.
- 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.
- 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:
-
Local check. The Connector looks up the click’s opaque key in the durable
slack_tool_approvalsrow. The click’s workspace and user must match the row’s requester. Button values carry nothing else, and modalprivate_metadatais treated as a hint that every action re-verifies. A key replayed onto another channel or message is refused. -
Bridge check. The Connector mints an OAuth-federation
a2a:task.readcontinuation token for the original task and requester subject (slack:<team>/<user>). It presents that token to the request’srequesterApprovalUrl(/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 agent owner opted in with
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:
- It is a bridge-relative path, validated on the RAW string by connector-kit’s
parseA2AToolApprovalRequesterUrlbefore any URL normalization: exactly/agents/<id>/approvals/<requestId>, the request id matching the event, with no literal./..segments, encoded separators, query, fragment, or absolute URL. - It is joined onto the origin of the task’s A2A endpoint, which is the token’s resource. That origin must be trusted.
- It uses https. A loopback http bridge is allowed only with
MENTIONABLE_ALLOW_PRIVATE_ADDRESSES=1, and private hosts are refused otherwise.
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.
- The first writer owns the binding, so replayed or reconnected events never bind twice.
- One click wins the decision claim (
pending → deciding). Concurrent Allow/Deny clicks submit at most one POST. If the POST’s response is lost, the claim staysdecidingand the UI says the outcome is being checked; the reconciler asks the bridge (GET) before anyone can decide again. - One path wins result delivery (
→ delivering). A livedeliveringclaim is never taken over; a stale one (crash) is.
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:
- Every logical message (the card; each result message index) has a durable
ledger entry (
slack_tool_approval_messages). Before ANY POST — including the creator’s first card post — one atomic insert moves it from ready to uncertain for a single attempt; whoever loses that CAS never posts. Leases only schedule workers; they never authorize a post. - An uncertain entry only becomes sent: when Slack returned the message ts,
or when a retry finds the marked message in the thread
(
conversations.replieswithinclude_all_metadata, every page, authored by this bot as verified byauth.test). Lease expiry, timeouts, a paused writer, or an absent / unavailable lookup never make it ready again, so a late old request can at worst land that one message itself. - Only a response proving Slack did not create the message (an explicit list
of rejections such as
invalid_blocks,channel_not_found,not_in_channel,invalid_auth, a rate-limit rejection) releases it for a retry. Genericok: false,fatal_error/internal_error, 5xx, network errors and timeouts are unknown. These POSTs use a client with the SDK’s automatic retries disabled and rate limits rejected, so one ledger attempt is one HTTP request from this process. - Every message carries Slack message metadata (
event_type: mentionable_tool_approval; card: approval key; result: bridge origin, task, execution and index — non-secret, readable by channel members).
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:
- posts or adopts cards whose first post failed or was not recorded;
- reads the original task with
tasks/getand a fresh task.read continuation token (nevermessage/send), and consumes the snapshot only whenTask.metadata[URI].executionIdequals the bound execution. A different execution invalidates the request and abandons delivery; a snapshot without the marker is never consumed; - delivers a terminal or
input-requiredresult through the ledger (AskUserQuestion questions are rendered with the normal interactive blocks) and appends the reply to the thread’s A2A history like a streamed reply. The result is selected like the live single-shot client (status message, else an agent message from the current turn — after the last user message, so never an earlier execution’s answer on a reused task — else the current execution’s answer-artifact text) with the same decoding; distinct non-text answer-artifact parts (file / data) are kept alongside the text, while the approval prompt / decision notice and traceability artifacts are excluded. File / image parts are not rendered, exactly as in live replies: the reference Connector does not support agent file output (uploads) today; - binds a follow-on approval request only from the same execution;
- resolves unconfirmed decisions and reflects expiry, invalidation and web-console decisions from the bridge GET (authoritative), falling back to “outcome unknown” when only same-execution evidence or a passed deadline is available;
- repairs cards whose
chat.updatefailed, and stops polling two hours after the approval deadline with a notice.
Setup
All of the following are required. If any is missing, the feature stays off and threads get the argument-free notice instead.
| Requirement | Notes |
|---|---|
| Bridge with tool approvals | vicoop-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-in | requester_approvals_enabled on the bridge agent (default false). |
| Runtime opt-in | remote_approvals / approval_decision: "remote" in the bridge client config (see tool-approval v1). |
MENTIONABLE_TOOL_APPROVAL_TRUSTED_ORIGINS | Comma-separated bridge origins, e.g. https://bridge.example.com. |
POSTGRES_URL | Durable store; slack_tool_approvals is created on first use. There is no in-memory fallback. |
| OAuth federation | MENTIONABLE_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 scopes | The 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:
- Vercel Pro: change that cron’s schedule in
vercel.jsonto* * * * *. - Any plan: an external scheduler (GitHub Actions, cron-job.org, a systemd
timer, …) sending
curl -H "Authorization: Bearer $CRON_SECRET" https://<host>/api/cron/reconcile-tool-approvals.
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
- Agent-relay turns (no provable local requester) and Slack Connect external users get the console notice instead of a review button.
- A recovered result repeats the full final reply text (the reconciler cannot tell which part was already shown in the placeholder).
- Approval state on the bridge is in memory. After a bridge restart the request is gone; Slack shows “outcome could not be confirmed” after the deadline, and an execution replacement invalidates it.