Can I stream structured tool's ouput?

Hello all,

Problem :
Before i was using StreamObject to stream tasks, but now my app is more complicated so i needed tools so i switched to streamText() which works well, the only thing i miss the object streaming feature, the tools inside streamText generates well an object + stream the text after the tool usage , but not streaming the tool structured output.

Question : is it possible please to stream the tool structured output instead of waiting long time for generating it? thanks.

streamText code :

        const result = streamText({
            model: mistral('mistral-small-latest'),
            maxSteps: 3,
            toolCallStreaming: true,
            system: getMeetingModalSystemPrompt(context, promptRouter.result),
            messages,
            tools: {
                proposeTodoCreation,
                meetingCreation,
                noteCreation,
            },
        });

Tool code :

export const noteCreation = tool({
    description: 'Use this tool when the user ask to generate a note or sumamry of meeting',

    parameters: z.object({
        note: z
            .object({
                subjects: z.string().describe('main Subjects disscused during the meeting, be detailed'),
                futureActions: z.string().describe('planned tasks for future, be detailed'),
            })
            .describe('create a detailed meeting summary'),
    }),

    execute: async ({ note }) => note,
});

thank you !

1 Like

You can’t stream tool results but you can stream arguments with partial tool calls..

2 Likes

hello Nico, yes i tried but it didnt work neither , but thanks for your answer !

Currently, streamText() doesn’t support streaming structured tool outputs only the tool call and the final text. Streaming the structured output isn’t implemented yet, but would definitely be useful. Hope it’s added soon!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.