| @@ -43,9 +43,16 @@ | ||
| 43 | 43 | let segment = []; |
| 44 | 44 | for (const { type, details } of get().messages) { |
| 45 | 45 | const finished = ['completed', 'canceled'].includes(details.status); |
| 46 | 46 | if (['workflow', 'workflow-component'].includes(type) && finished) { |
| 47 | - segments.push({ workflowId: details.workflowId, segment }); | |
| 47 | + // A canceled run's reply claims a change the next run then skips. | |
| 48 | + const kept = | |
| 49 | + details.status === 'canceled' | |
| 50 | + ? segment.filter( | |
| 51 | + (m) => m.role !== 'assistant' || typeof m.content !== 'string', | |
| 52 | + ) | |
| 53 | + : segment; | |
| 54 | + segments.push({ workflowId: details.workflowId, segment: kept }); | |
| 48 | 55 | segment = []; |
| 49 | 56 | continue; |
| 50 | 57 | } |
| 51 | 58 | // An error ended a run without a marker; what precedes it is dead. |