Repository navigation
feat: let agents read the owner's replies in a tracked Slack channel - #30735
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. The read reuses the inbound gate's existing admission decisions (tracked channel, channels policy, workspace origin, Notes
[DESIGN-REVIEWED] 76cc7d5 Description read[DESCRIPTION-READ] aeda9e5a6f3aa05739abf593436f0009366bcee16d86b954a03d43ac4ea2aad9 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: each item traces to #18747's send-only gap or to a boundary already on record (the inbound sender gate, channel-agent containment). The one undeclared rider is a harm-free retry on the gate's own lookup. What this change shipsInventory (7 items) — 6 justifiedIntent: An unattended agent can see the owner's Slack reply (an approval, a follow-up) in a tracked channel or thread. ADDITION (Closes #18747).
[FIRST-PRINCIPLES-REVIEWED] 76cc7d5 Description read[DESCRIPTION-READ] 0157fa495ae438d2b11f0b8cb599d030c64ec83244d7e1b5033d50d449166ad7 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
84d729e to
3eafcf6
Compare
|
[operator: bolichen97]
|
|
[operator: bolichen97]
|
3eafcf6 to
b91cd72
Compare
|
[operator: bolichen97]
|
b91cd72 to
63ede75
Compare
ba0aaf6 to
41aab35
Compare
|
Rebased: main moved in [operator: bolichen97] |
buluoray
left a comment
There was a problem hiding this comment.
🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:
APPROVE at 41aab35.
What it does for users: an agent, including an unattended cron agent, can check whether the owner replied in a Slack channel the owner tracks, or in one thread there. An approval given in Slack can then move the agent forward, and the owner no longer has to repeat it in the dashboard.
Evidence for the read boundary
- Only the owner's words come back. The route returns text only when is_allowed_user(user) is true, and returns empty text with admitted false otherwise (src/kiro_crew/dashboard/messaging_api/slack_workspace.py, the loop at the end of api_slack_history). At this head is_allowed_user is exactly is_owner (slack/handler_runtime/access.py:245-253: "only the owner ... is authorized"). The tool then runs credential and exfiltration-URL redaction again before the model sees the text (mcp_tools/messaging.py, read_slack_history).
- Only a channel the owner chose to track. is_tracked_channel is checked first (access.py:273, membership in the tracking set the owner's track approval fills). After that come the inbound channels policy (channel_refusal plus channel_inbound_permitted) and the workspace origin gate (check_message_origin on the channel's own team). All of these run before any Slack call.
- Containment. The route is on the strict internal path list (dashboard/server_internal_paths.py:125), so it needs loopback plus the internal secret and has no browser caller. The tool requires a strict caller identity and refuses a channel agent at dispatch (_deny_channel_agent_messaging). The name is also on CHANNEL_AGENT_BLOCKED_TOOLS (channel.py:196), so the permission matcher refuses it too.
- Stateless. Each call is one request to the route, which does one bounded Slack read (fetch_history: at most 20 pages of 200) and keeps nothing apart from the audit record. Polling belongs to the agent, which passes oldest.
- Mutation 1: making the text unconditional (dropping "if admitted else ''") reddens test_slack_history_read.py::test_only_the_owners_text_comes_back. Another person's text then reaches the response.
- Mutation 2: removing the tracked-channel check reddens test_slack_history_read.py::test_an_untracked_channel_is_refused_before_any_slack_read (200 instead of 403). The worktree was clean after each mutation, and they were run one at a time.
- Tests: test_slack_history_read.py together with the five registration pin files and test_fetch_thread_replies.py, 353 passed. CI on this head: 78 success, 18 skipped, 0 failing. PR Readiness success. GPT, Opus, Design and First Principles all pass and UX is skipped. There are no review threads. It merges cleanly onto main (merge-tree exit 0).
Value gate: passes. The need is filed (#18747) and two earlier community attempts preceded this one. The only existing way to read a reply is the separate per-user OAuth Slack MCP server, which an unattended agent on a plain install does not have. The new agent-facing surface is read-only and admits no sender the inbound gate refuses.
Disposition of the Design lane note on this head: the note says text comes back for any sender is_allowed_user admits, which on a multi-user allow-list would be more than the owner. At this head is_allowed_user admits the owner only (access.py:245-253), so "the owner" in the tool description is accurate. This does not gate.
Source-only: the new tests patch is_allowed_user to an owner check, so the real gate function is not exercised through this route. The owner-only claim rests on reading access.py. Nothing ran against a live Slack workspace, and the conversations.replies page shapes come from fakes.
Follow-ups (non-blocking)
- The route uses whatever is_allowed_user returns. If that gate is ever widened past the owner, this read widens with it, and the tool description, the slack-gateway spec line and the feature-map row would then be false. A test that drives the route through the real is_allowed_user with a non-owner allow-list entry would pin that.
- The audit records for this route log session_key "dashboard" and not the verified caller the tool forwards. That matches the profile route beside it, but it means an operator cannot tell from the audit which session read a channel.
|
Re-sync budget reset. Maintainer decision: this PR is approved and green at 41aab35, but main has since changed the MCP route-table pin this PR also edits, so it now conflicts. One more rebase is needed to land it, and the approval will need renewing on the new head. [operator: bolichen97] |
41aab35 to
b5824e4
Compare
|
Rebased: main moved in [operator: bolichen97] |
An agent can post to Slack but cannot read what was said back, so a "wait for the owner to approve in a thread" loop has nowhere to read the answer. Add a read_slack_history MCP tool: it reads one tracked channel's timeline, or one thread, with the bot token the install already holds. The read adds no new way in. Any channel outside the tracked list is refused, a channel agent is refused at dispatch, and text comes back only for messages whose sender the inbound gate admits (the owner). Anyone else's message is listed with admitted false and no text. Bot posts are dropped before the limit applies, so a run of them cannot hide a reply, and a failed Slack read is an error, never an empty list. Reading the owner's DMs stays out of scope. Builds on #18748 by @iamwhatever and #7930 by @Patcurley1. Co-authored-by: Patcurley1 <101998702+Patcurley1@users.noreply.github.com>
b5824e4 to
76cc7d5
Compare
|
[operator: bolichen97] New head 76cc7d5: rebased onto main 10e0a06 (main fixed the shared shard-7 allowlist red in #31803, and the persistent-agent-channels spec conflict is resolved keep-both with main's The local pre-push review found two defects in this PR's own code, both fixed with a red/green test in
The approval on 41aab35 needs renewing on this head. |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved for the on-call. Review lanes pass on 76cc7d5, no conflict, no open change request.
Problem / Motivation
Goal: An agent can read the owner's reply in a tracked Slack channel or thread, so an unattended agent can wait for an approval given in Slack.
Agents can send Slack messages (
send_message) and read a profile (read_slack_profile), but nothing reads what was said back. A "the owner approves in a thread, the agent picks it up" flow has to move to the dashboard chat, and an unattended cron agent has no way to see the answer at all unless the operator has set up the separate per-user OAuth Slack MCP server.Why it matters
Reply-driven Slack automation (approval loops, "reply here to continue") cannot be built today. The tool closes the send-only gap with the bot token the install already holds, and adds no new way in: it reads only channels the operator already tracks, and only the words of the sender the inbound gate already lets talk to the agent.
Not a goal
What changed (motivation → approach → change)
read_slack_historyMCP tool (mcp_tools/messaging.py)channel, optionalthread_ts,oldest(only later messages) andlimit(1-100, default 20). Returns[{user, ts, admitted, text}], newest firstPOST /api/slack-history(dashboard/messaging_api/slack_workspace.py)slack.allowed_enterprise_ids) does not admit. Text comes back only whenis_allowed_useradmits the sender; any other message hasadmitted: falseand empty text. A failed Slack read is a 502 with a non-empty error, never an empty list. Every refusal carries acodeRealSlackClient.fetch_history(slack/client.py)channels:history/groups:historyscopes thatfetch_thread_repliesalready reads channel threads with, keeps only messages afteroldest(a thread's parent included), drops bot posts before the limit applies, and raises on every error, a read that runs out of pages first includedThe shape mirrors
read_slack_profile(tool, then gateway route, then Slack client). It reuses the tracked-channel allowlist the pins and reactions routes apply, and the same channels-policy and workspace-origin checks the inbound message gate runs, so a channel or workspace the gate closes is closed to this read too. Text from a channel member the gate does not admit could carry instructions into an unattended agent. Of the two ways to stop that (wrap it as untrusted, or withhold it) this withholds it: the inbound gate already decides who may talk to the agent, and the read follows that decision instead of adding a second policy. A channel agent is refused at dispatch and listed inCHANNEL_AGENT_BLOCKED_TOOLS(channel.py), for the reasonsession_read_messageis: it could relay one channel's messages into its own thread. A thread is read to its last page, since replies arrive oldest first, and its parent, which Slack returns on every page whateveroldestsays, is kept once and only when it is newer thanoldest. Everything else is registration beside the profile tool's: the route indashboard/server_runtime/mcp_routes.pyanddashboard/server_internal_paths.py, its re-exports indashboard/handlers/, the argument schema invalidation_parts/messaging_session_schemas.py,validation_parts/server_registries.pyandvalidation.py, and the title indata/mcp_tool_titles.json.docs/architecture/mcp.md, the slack-gateway, messaging and persistent-agent-channels specs, and adocs/feature-map/README.mdrow describe the tool.Backwards compatibility
Compatible: a new tool, route and client method; no existing field, validator, route or tool changes.
Removes nothing: the diff only adds a read path.
Tests
test/test_slack_history_read.py: an untracked channel, a tracked one the policy refuses (the channel itself, or the Slack transport), and one whose workspace the origin check does not admit are refused before any Slack read; only the owner's text comes back; a failed Slack read is an error, a timeout with an empty message included; bot posts (bot_idorsubtype: bot_message) are dropped before the limit and the timeline stops paging once it has enough; a thread read pages to its newest reply and drops what is not afteroldest; a parent repeated on every page comes back once; a timeline or thread read past the page cap raises; the tool refuses a channel agent (at dispatch and in the permission-prompt list); the tool forwards its arguments with the verified caller key and redacts the text. Each of those guards was reverted once and its test went red.test_dashboard_server_composition_contract_reach.py(MCP route table rows and digest),test_handlers_messaging_composition_contract.py(re-export count),test_messaging_api_non_object_body.py(non-object body row),test_remote_session_local_only_tools.py(remote-safe core tool),test_validation_parts_facade.py(schema name).-n0, 10/10 at-n 4 --dist loadgroup --max-worker-restart=2besidetest_send_message_targeted.pyandtest_fetch_thread_replies.py, and in a shuffled order (seed 17311).Manual verification
Not run against a live Slack workspace. The unit tests drive the route through aiohttp, the client through a fake web client returning real
conversations.history/conversations.repliespage shapes, and the tool through the MCP dispatcher.Screenshots / video
N/A — no frontend change.
Related Issues
Closes #18747
Builds on #18748 by @iamwhatever, which reworked #7930 by @Patcurley1.
Sibling sweep
N/A — feature PR.
Pattern harvest
N/A — feature PR.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license (see CONTRIBUTING.md).