Repository navigation
Agent-authored Slack Block Kit components in respond_to_user - #23
Open
josephschorr wants to merge 1 commit into
Open
josephschorr wants to merge 1 commit into
josephschorr wants to merge 1 commit into
Conversation
Let the agent compose presentational Block Kit layout in Slack replies via a new `blocks` field on respond_to_user, gated by a "components" channel capability. A channel kind opts in by implementing the new ComponentFormatter and ComponentValidator interfaces (channel-neutral seam, Slack-native content): respond_to_user injects the kind authoring instructions into the blocks schema, validates synchronously in the runner before publish — returning a precise, model-facing error instead of a post-time degrade — and carries the validated blocks on OutboundUserMessagePayload.Components. The Slack sender renders them as the message body with the text field as the notification/degrade fallback, and the info-leakage egress gate measures block text via ComponentsPlainText. Supported read-only blocks: header, section (no accessory), divider, context, rich_text, markdown, table, data_visualization, card (no actions), container, plan, task_card. Interactive blocks/elements, images (deferred), and @channel/@here/@everyone broadcasts are rejected with precise errors. Chart and container payload shapes are validated to Slack requirements verified against the live API (container needs a title; charts need per-type segments/series + axis_config). Upgrade slack-go v0.23.1 -> v0.30.1 for typed support of the newer blocks, adapting the variadic GetUserInfoContext signature change.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Lets an agent compose presentational Slack Block Kit layout in its replies — not just a markdown string. The agent passes a
blocksarray onrespond_to_user; the Slack kind renders it as the message body, with the existingtextfield as the notification preview and degrade fallback.How
Channel-neutral seam, Slack-native content — no
kind == "slack"branch leaks into the agent tool:"components"capability onchannelkinds.Kind(Slack opts in). Flows toChannelBinding.Capabilities→respond_to_user, exactly like"markdown".TextFormatter):ComponentFormatter(model-facing authoring instructions, injected into theblocksschema description) andComponentValidator(ValidateComponents+ComponentsPlainText). The runner already blank-imports the Slack kind, so both are reachable in-process.respond_to_usercalls the kind's validator synchronously; a bad payload returns a precise, model-facingIsError(no envelope published) instead of a silent post-time degrade to plain text.OutboundUserMessagePayload.Components json.RawMessage; the Slack sender posts it viaMsgOptionBlockswithtextas fallback, keeping the existing blocks→plaintext degrade net.ComponentsPlainText), so content can't bypass the gate by riding inblocks.Supported blocks (read-only / presentation-only)
header,section(no accessory),divider,context,rich_text,markdown,table,data_visualization(line/bar/area/pie charts),card(no actions),container,plan,task_card.Rejected with precise, correctable errors: interactive blocks/elements (
actions,input,context_actions,data_table,carousel, section accessories, card actions),alert(modals-only), images/icons (deferred — see Scope), and@channel/@here/@everyonebroadcasts. Chart and container payload shapes are validated to Slack's actual requirements — verified against the live API — so the agent gets a clean error rather than a degrade (container needs atitle/rich_text_title; charts need atitleplus per-typesegmentsorseries+axis_config.categories).slack-go upgrade
Bumps
github.com/slack-go/slackv0.23.1 → v0.30.1 for typed support of the newer blocks (data_visualization,table,card,container,markdown,plan,task_card, …). The only breaking change wasGetUserInfoContextbecoming variadic; the Slack wrapper interfaces and test fakes are adapted to match.Scope
Slice 1 is presentational only. Interactivity (buttons/menus routing clicks back into the session) is out of scope. Images are deferred to Slice 2 (artifact-backed — resolve a session-owned artifact handle rather than an arbitrary URL).
Testing
respond_to_usertests against the real Slack validator: schema exposesblocksonly under the capability; validation failure →IsError, no publish; success carriesComponents; a leakage-gate test proves block-only content is still measured.Follow-ups (tracked, not in this PR)
invalid_blocksback to the agent as a system note for any future/unknown block that passes our validator but Slack still rejects (channelsd → session feedback), instead of only degrading.