feat: update message handling to use 'finish' property for step completion logic

This commit is contained in:
Bohdan Triapitsyn
2025-12-27 15:51:28 +02:00
parent 88e0cedcd3
commit 4d7340bf49
11 changed files with 60 additions and 134 deletions
+1 -1
View File
@@ -590,7 +590,7 @@ export const debugUtils = {
const lastMessage = assistantMessages[assistantMessages.length - 1];
const stepFinishParts = lastMessage.parts.filter((p: any) => p.type === 'step-finish');
const hasStopReason = lastMessage.parts.some((p: any) => p.type === 'step-finish' && p.reason === 'stop');
const hasStopReason = (lastMessage.info as { finish?: string }).finish === 'stop';
const timeInfo = lastMessage.info.time as any;
const completedAt = timeInfo?.completed;
+2 -3
View File
@@ -11,6 +11,7 @@ export interface MessageInfo {
};
status?: string;
streaming?: boolean;
finish?: string;
}
export interface MessageRecord {
@@ -27,9 +28,7 @@ export function isMessageComplete(messageInfo: MessageInfo, parts: Part[] = []):
const completedAt = typeof timeInfo?.completed === 'number' ? timeInfo.completed : undefined;
const messageStatus = messageInfo?.status;
const hasStopFinish = parts.some(part =>
part.type === 'step-finish' && (part as any).reason === 'stop'
);
const hasStopFinish = messageInfo.finish === 'stop';
const hasCompletedFlag = (typeof completedAt === 'number' && completedAt > 0) || messageStatus === 'completed';
if (!hasCompletedFlag || !hasStopFinish) {