Skip to content

Commit 5cea560

Browse files
committed
fix(ag-ui): preserve interrupt types in non-strict consumers
1 parent bc99636 commit 5cea560

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

libs/ag-ui/src/lib/interrupt-session.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ export class InterruptSession {
1313
observeNative(entries: unknown[], runId?: string): void {
1414
if (entries.length === 0) throw new Error('Native interrupt outcome must contain interrupts');
1515
if (this.isLateObservation(runId)) return;
16-
const parsed = entries.map(entry => InterruptSchema.passthrough().parse(
17-
isRecord(entry) && entry['reason'] === undefined ? { ...entry, reason: '' } : entry,
18-
));
16+
const parsed = entries.map(entry => {
17+
const normalized = isRecord(entry) && entry['reason'] === undefined ? { ...entry, reason: '' } : entry;
18+
// Keep the SDK's declared output type across consumer strictness settings.
19+
// Preserve extensions separately instead of re-inferring a passthrough schema.
20+
const validated = InterruptSchema.parse(normalized);
21+
return { ...(isRecord(normalized) ? normalized : {}), ...validated };
22+
});
1923
if (new Set(parsed.map(entry => entry.id)).size !== parsed.length) throw new Error('Duplicate interrupt id');
2024
this.beginObservation(runId);
2125
const merged = new Map(this.state.interrupts.map(entry => [entry.id, entry]));

0 commit comments

Comments
 (0)