Skip to content

Commit fa63cfe

Browse files
committed
feat(slack): stream an Agent's tool-call timeline without its text
Slack triggers gain streamTimelineSources (Agent blocks, including child workflows) and streamToolLabels. A timeline source streams through the executor as usual, but only its tool steps and optional thinking reach Slack; its text is drained and never posted. The first message of an execution is shared by timeline steps and the first answer, and is owned and stopped by the controller. Deployed configs without the new fields read as empty, so no redeploy is needed.
1 parent 38d9b31 commit fa63cfe

12 files changed

Lines changed: 715 additions & 122 deletions

File tree

‎apps/docs/content/docs/integrations/slack.mdx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ Custom-bot Slack triggers can stream workflow outputs directly back into the con
3131
- Loop and parallel invocations each create their own Slack response.
3232
- The response status label defaults to `Running` and can be customized in the trigger's advanced settings.
3333
- Optional thinking and tool-call updates appear as Slack tasks in a timeline or plan.
34+
- **Show progress from** (`streamTimelineSources`) shows an Agent's tool steps, and its thinking when enabled, without posting its text. Use it when an Agent's output is reviewed or reformatted by a later block: the steps and the first streamed answer share one Slack reply. Agents in child workflows can be selected. A block cannot be both an output to stream and a progress source.
35+
- **Tool step labels** (`streamToolLabels`) renames tool steps by tool name, for example `lc_cur` → `Reading AWS cost data`. Unlisted tools use a generated name. Steps never show tool arguments.
36+
- With PII block-output redaction on, Agent output is not streamed live, so no progress steps appear; selected outputs are still sent when their block completes.
3437
- Slack Agent Sessions remain in processing state for the run, return to active when it finishes, and the native Slack stop button cancels active workflow executions.
3538

3639
Automatic trigger responses require a custom bot created by the Slack setup wizard. They are not available with the shared Sim Slack app. Where the deployment enables shared-app triggers, the Sim app can receive its subscribed event subset without automatic streaming.
@@ -3867,6 +3870,8 @@ Trigger from Slack events, interactions, and slash commands
38673870
| `threads` | string | No | Include thread replies, exclude them \(top-level only\), or fire only on thread replies. |
38683871
| `streamResponse` | boolean | No | Create a Slack agent session and stream selected workflow outputs into the conversation that started this run. Custom bots only. |
38693872
| `streamOutputs` | workflow-output-selector | No | Use `<blockName>.<outputPath>` for this workflow or `<childWorkflowId>.<blockName>.<outputPath>` for a child workflow. Selecting a child workflow applies to every invocation of it. Agent outputs stream live; other outputs are sent when the block completes. |
3873+
| `streamTimelineSources` | workflow-output-selector | No | Agent blocks, including ones in child workflows, whose tool steps appear in the reply while they run. Their text is never posted. No steps appear when PII block-output redaction is on. |
3874+
| `streamToolLabels` | table | No | Optional names for tool steps, keyed by tool name \(an MCP tool by its own name, like lc_cur\). Unlisted tools use a generated name. |
38703875
| `streamTaskTitle` | string | No | Optional status Slack shows while each selected response is being produced. Leave empty to use Running. |
38713876
| `streamTaskDisplayMode` | string | No | Choose how Slack displays thinking and tool progress. |
38723877
| `streamIncludeThinking` | boolean | No | Show agent thinking as Slack task updates while the response is generated. |

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components/output-select/output-select.tsx‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ interface OutputSelectProps {
4242
disabled?: boolean
4343
/** Placeholder text when no outputs are selected */
4444
placeholder?: string
45+
/** Offers only this output path of blocks of this type */
46+
outputFilter?: { blockType: string; path: string }
4547
/** Whether to emit internal IDs, display labels, or public dot selectors */
4648
valueMode?: 'id' | 'label' | 'public'
4749
/** Alignment of the dropdown relative to the trigger */
@@ -127,6 +129,7 @@ function OutputSelectContent({
127129
onOutputSelect,
128130
disabled = false,
129131
placeholder = 'Select outputs',
132+
outputFilter,
130133
valueMode = 'id',
131134
align = 'start',
132135
maxHeight = 200,
@@ -206,14 +209,20 @@ function OutputSelectContent({
206209
const thirdLevelStates = useWorkflowStates(thirdLevelWorkflowIds)
207210

208211
const workflowStates = new Map([...firstLevelStates, ...secondLevelStates, ...thirdLevelStates])
209-
const workflowOutputs = workflowId
210-
? buildWorkflowOutputOptions({
211-
rootWorkflowId: workflowId,
212-
rootState,
213-
workflowStates,
214-
maxChildDepth: DEFAULTS.MAX_SSE_CHILD_DEPTH,
215-
})
216-
: []
212+
const workflowOutputs = (
213+
workflowId
214+
? buildWorkflowOutputOptions({
215+
rootWorkflowId: workflowId,
216+
rootState,
217+
workflowStates,
218+
maxChildDepth: DEFAULTS.MAX_SSE_CHILD_DEPTH,
219+
})
220+
: []
221+
).filter(
222+
(output) =>
223+
!outputFilter ||
224+
(output.blockType === outputFilter.blockType && output.path === outputFilter.path)
225+
)
217226
const outputMenu = buildWorkflowOutputMenu(workflowOutputs)
218227
const outputMenuRevision = JSON.stringify([
219228
workflowId,

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/workflow-output-selector/workflow-output-selector.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface WorkflowOutputSelectorProps {
1111
previewValue?: string[] | null
1212
disabled?: boolean
1313
placeholder?: string
14+
outputFilter?: { blockType: string; path: string }
1415
}
1516

1617
export function WorkflowOutputSelector({
@@ -20,6 +21,7 @@ export function WorkflowOutputSelector({
2021
previewValue,
2122
disabled = false,
2223
placeholder,
24+
outputFilter,
2325
}: WorkflowOutputSelectorProps) {
2426
const workflowId = useWorkflowRegistry((state) => state.activeWorkflowId)
2527
const [storedValue, setStoredValue] = useSubBlockValue<string[]>(blockId, subBlockId)
@@ -34,6 +36,7 @@ export function WorkflowOutputSelector({
3436
onOutputSelect={setStoredValue}
3537
disabled={disabled || isPreview}
3638
placeholder={placeholder}
39+
outputFilter={outputFilter}
3740
valueMode='public'
3841
size='md'
3942
className='w-full'

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/sub-block.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,7 @@ function SubBlockComponent({
11521152
previewValue={previewValue as string[] | null | undefined}
11531153
disabled={isDisabled}
11541154
placeholder={config.placeholder}
1155+
outputFilter={config.outputFilter}
11551156
/>
11561157
)
11571158

‎apps/sim/blocks/blocks/slack.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3551,6 +3551,7 @@ export const SlackV2Block: BlockConfig = {
35513551
'Build Slack workflows with messages, conversations, files, reactions, pins, bookmarks, user groups, profiles, Lists, canvases, and Agent Sessions. Operations that need additional app scopes use custom Slack bots. Lists require lists:read/lists:write and a paid Slack plan. Native Sim connections retain their existing permissions. Page through list outputs explicitly.',
35523552
bestPractices: `${SlackBlock.bestPractices}
35533553
Native agent-session streaming uses a custom Slack bot and a supported trigger event. Enable streamResponse and select the intended outputs in streamOutputs; Sim Chat (mothership) streams its content output. The trigger owns the streamed reply, so another send needs a separate purpose.
3554+
To show an Agent's tool steps without posting its text (for example an analyst whose output a later block reviews), list that Agent in streamTimelineSources instead of streamOutputs, and optionally name its tools in streamToolLabels.
35543555
The custom-bot manifest's baseline agent scopes are ${SLACK_AGENT_SCOPES.join(', ')}. Selected capabilities add their required scopes and event subscriptions. Verify the installed app's grants, resource access and event configuration; a saved credential or edited manifest alone does not prove access.
35553556
streamIncludeToolCalls displays tool activity; it does not authorize tool execution. Configure Sim Chat's selected operations and their credentials separately. Choose streamIncludeThinking deliberately for the destination audience.
35563557
Block Kit messages can contain buttons, selects and forms, but interactions require the app's interactivity request URL and the corresponding interaction trigger. Treat message events, button/select callbacks and modal submissions as separate paths. A control's action_id/value correlates work; runtime actor and state checks authorize it.`,

‎apps/sim/blocks/types.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ export interface SubBlockConfig {
393393
min?: number
394394
max?: number
395395
columns?: string[]
396+
/** Limits a `workflow-output-selector` to one output path of the given block type. */
397+
outputFilter?: { blockType: string; path: string }
396398
placeholder?: string
397399
/**
398400
* Conceals the stored value in the editor until the field is focused.

‎apps/sim/lib/webhooks/slack-execution-stream.test.ts‎

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ const BASE_CONFIG: SlackStreamResponseConfig = {
4949
includeToolCalls: true,
5050
taskTitle: 'Running',
5151
taskDisplayMode: 'plan',
52+
timelineSources: [],
53+
toolLabels: {},
5254
}
5355

5456
function createLoggingSession() {
@@ -729,6 +731,113 @@ describe('SlackExecutionStreamController', () => {
729731
controller.assertSucceeded()
730732
})
731733

734+
describe('timeline sources', () => {
735+
const TIMELINE_CONFIG: SlackStreamResponseConfig = {
736+
...BASE_CONFIG,
737+
outputConfigs: [{ blockId: 'reply', path: 'result' }],
738+
timelineSources: [{ workflowId: 'child-workflow', blockId: 'analyst' }],
739+
toolLabels: { lc_cur: 'Reading AWS cost data' },
740+
}
741+
const TIMELINE_EVENTS: AgentStreamEvent[] = [
742+
{ type: 'tool_call_start', id: 'tool-1', name: 'mcp-6da535c1-lc_cur' },
743+
{ type: 'tool_call_end', id: 'tool-1', name: 'mcp-6da535c1-lc_cur', status: 'success' },
744+
{ type: 'tool_call_start', id: 'tool-2', name: 'mcp-6da535c1-lc_other' },
745+
{ type: 'tool_call_end', id: 'tool-2', name: 'mcp-6da535c1-lc_other', status: 'success' },
746+
{ type: 'text_delta', text: '{"secret":"analyst json"}', turn: 'pending' },
747+
{ type: 'turn_end', turn: 'final' },
748+
]
749+
750+
async function streamTimeline(
751+
controller: SlackExecutionStreamController,
752+
events: AgentStreamEvent[] = TIMELINE_EVENTS
753+
) {
754+
await controller.callbacks.onStream?.({
755+
blockId: 'child-workflow.analyst',
756+
childWorkflowInstanceId: 'child-instance-1',
757+
executionOrder: 2,
758+
stream: createByteStream('{"secret":"analyst json"}'),
759+
clientStreamTransformed: false,
760+
subscribe: ({ onEvent }) => {
761+
for (const event of events) void onEvent(event)
762+
return vi.fn()
763+
},
764+
})
765+
}
766+
767+
function allChunks(): SlackStreamChunk[] {
768+
return [
769+
...mockStartSlackAgentStream.mock.calls.flatMap((call) => call[2]),
770+
...mockAppendSlackAgentStream.mock.calls.flatMap((call) => call[3]),
771+
...mockStopSlackAgentStream.mock.calls.flatMap((call) => call[6] ?? []),
772+
]
773+
}
774+
775+
it('streams the source as a block selector so the executor streams it', async () => {
776+
const { controller } = await createController(TIMELINE_CONFIG)
777+
expect(controller.selectedOutputs).toEqual(['reply_result', 'child-workflow.analyst_content'])
778+
})
779+
780+
it('shows tool steps without the source text and posts the answer in the same message', async () => {
781+
const { controller } = await createController(TIMELINE_CONFIG)
782+
await streamTimeline(controller)
783+
await controller.callbacks.onBlockComplete?.('reply', 'Reply', 'function', {
784+
output: { result: 'Reviewed answer' },
785+
executionOrder: 3,
786+
executionTime: 1,
787+
startedAt: '2026-11-24T00:00:00Z',
788+
endedAt: '2026-11-24T00:00:01Z',
789+
})
790+
await controller.finalize({ success: true, status: 'completed', output: {} })
791+
792+
controller.assertSucceeded()
793+
expect(mockStartSlackAgentStream).toHaveBeenCalledTimes(1)
794+
expect(mockStopSlackAgentStream).toHaveBeenCalledTimes(1)
795+
const text = allChunks()
796+
.filter((chunk) => chunk.type === 'markdown_text')
797+
.map((chunk) => (chunk.type === 'markdown_text' ? chunk.text : ''))
798+
.join('')
799+
expect(text).toBe('Reviewed answer')
800+
const toolTitles = allChunks().flatMap((chunk) =>
801+
chunk.type === 'task_update' && chunk.id.includes('-tool-') ? [chunk.title] : []
802+
)
803+
expect(new Set(toolTitles)).toEqual(new Set(['Reading AWS cost data', 'Lc Other']))
804+
expect(mockStopSlackAgentStream.mock.calls[0][3]).toBe('processing')
805+
})
806+
807+
it('stops a timeline-only message once with an error status when the run fails', async () => {
808+
const { controller } = await createController(TIMELINE_CONFIG)
809+
await streamTimeline(controller, [
810+
{ type: 'tool_call_start', id: 'tool-1', name: 'mcp-6da535c1-lc_cur' },
811+
])
812+
await controller.finalize({ success: false, status: 'failed', output: {} })
813+
814+
expect(mockStartSlackAgentStream).toHaveBeenCalledTimes(1)
815+
expect(mockStopSlackAgentStream).toHaveBeenCalledTimes(1)
816+
expect(mockStopSlackAgentStream.mock.calls[0][3]).toBe('suspended')
817+
expect(mockStopSlackAgentStream.mock.calls[0][6]).toEqual(
818+
expect.arrayContaining([
819+
expect.objectContaining({ type: 'task_update', title: 'Running', status: 'error' }),
820+
expect.objectContaining({
821+
type: 'task_update',
822+
id: expect.stringContaining('-tool-tool-1'),
823+
status: 'error',
824+
}),
825+
])
826+
)
827+
})
828+
829+
it('still rejects a stream from a block in neither list', async () => {
830+
const { controller } = await createController(TIMELINE_CONFIG)
831+
await expect(
832+
controller.callbacks.onStream?.({
833+
blockId: 'other',
834+
executionOrder: 1,
835+
stream: createByteStream(),
836+
})
837+
).rejects.toThrow('unselected block')
838+
})
839+
})
840+
732841
it('rejects credentials that do not belong to the workflow workspace', async () => {
733842
mockGetSlackBotCredential.mockResolvedValue({
734843
botToken: 'xoxb-token',

0 commit comments

Comments
 (0)