fix: preserve structured attachment outputs (#17)
This commit is contained in:
@@ -666,7 +666,10 @@ export class MessageTurnController {
|
||||
await this.flushPendingProgress(options.flushPendingText);
|
||||
}
|
||||
|
||||
const replaceMessageId = this.consumeProgressForFinalDelivery();
|
||||
const hasAttachments = (options?.attachments?.length ?? 0) > 0;
|
||||
const replaceMessageId = hasAttachments
|
||||
? this.discardProgressForAttachmentFinalDelivery()
|
||||
: this.consumeProgressForFinalDelivery();
|
||||
await this.deliverFinalText(text, {
|
||||
...(options?.attachments?.length
|
||||
? { attachments: options.attachments }
|
||||
@@ -690,6 +693,20 @@ export class MessageTurnController {
|
||||
return replaceMessageId;
|
||||
}
|
||||
|
||||
private discardProgressForAttachmentFinalDelivery(): null {
|
||||
this.log.info(
|
||||
{
|
||||
progressMessageId: this.progressMessageId,
|
||||
latestProgressText: this.latestProgressText,
|
||||
},
|
||||
this.progressMessageId
|
||||
? 'Discarding tracked progress replacement for final attachment delivery'
|
||||
: 'Delivering final attachment output without a tracked progress message to replace',
|
||||
);
|
||||
this.resetProgressState();
|
||||
return null;
|
||||
}
|
||||
|
||||
private async deliverFinalText(
|
||||
text: string,
|
||||
options?: {
|
||||
|
||||
Reference in New Issue
Block a user