Problem
I’m developing a Slack AI app and trying to implement a debug mode where the end of the Slack message shows details about tool calls and results. I’m unable to stream text and capture the tools after each step or at the end because accessing the tool data consumes the stream.
Code Example
const agentStream = await slackAgent.stream({ // simulating a user message prompt: "What's the weather?",})
for await (const chunk of agentStream.textStream) { // send chunk to slack await slackStreamer.append({ markdown_text: chunk })}
// debug mode: add tool calls and tool results to the end of the slack message//! This doesn't work because "The tool calls that have been executed in the last step. Automatically consumes the stream."//? so we somehow need to not only text stream to slack but also capture tool calls right after each step.const toolCalls = await agentStream.toolCallsconst toolResults = await agentStream.toolResultsawait slackStreamer.append({ markdown_text: `Tool calls: ${JSON.stringify(toolCalls)}Tool results: ${JSON.stringify(toolResults)}` })
await slackStreamer.stop()
// this is also something I'm looking for:// const allToolCalls = ...// const allToolResults = ...I’m trying to capture toolCalls and toolResults right after each step or at the end of the stream without causing the stream to be automatically consumed.
Thank you, hopefully I don’t look too stupid, but I’ve spent hours testing and reading docs by now.