-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Message Concatenation Issue with Multiple Roundtrips #4654
Comments
+1 This is a breaking change and ideally should've been part of a major release. Also, version 4.1 release notes make NO mention of this change. As a workaround, I'm now adding annotations after every step completion in the // api/chat/route.ts
export async function POST(req: Request) {
return createDataStreamResponse({
execute: async (dataStream) => {
const result = streamText({
model,
system: `
You are a friendly assistant! Keep your responses concise and helpful.
`.trim(),
maxSteps: 10,
messages: messages,
tools: tools,
onStepFinish(event) {
dataStream.writeMessageAnnotation({
id: generateId(),
finishReason: event.finishReason,
isContinued: event.isContinued,
stepType: event.stepType,
text: event.text,
toolCalls: event.toolCalls,
toolResults: event.toolResults,
});
},
});
result.mergeIntoDataStream(dataStream);
},
});
} // /chat/page.tsx
// version 4.0.* compatible implementation
{/* {message.role === "assistant" && (
<AssistantMessage message={message} />
)} */}
// version 4.1.* compatible workaround
{message.role === "assistant" && (
<>
{message.annotations?.map((annotation) => (
<AssistantMessage key={annotation.id} message={annotation} />
))}
</>
)} |
same issue, this feature is better implemented as a param in |
+1 |
+1, just spent my day tracking this down 😓 |
Description
Version Information:
Components Affected:
Description:
After upgrading from version 4.0.33 to 4.1.16, there's an issue with how multiple roundtrip messages are handled. Instead of creating new messages for each roundtrip (as in 4.0.33), the SDK is now concatenating all content into a single message. This affects both streamed text and tool calls from subsequent roundtrips.
Current Behavior:
Expected Behavior:
Impact:
Code example
AI provider
@ai-sdk/openai v1.1.9
Additional context
No response
The text was updated successfully, but these errors were encountered: