feat(react): support interrupt_before/after

This commit is contained in:
Tat Dat Duong
2025-02-25 17:57:12 +01:00
parent 3257e5ae76
commit d3b9a96504
2 changed files with 9 additions and 4 deletions
+6 -1
View File
@@ -896,7 +896,12 @@ export function useStream<
if (isLoading) return undefined;
const interrupts = threadHead?.tasks?.at(-1)?.interrupts;
if (interrupts == null || interrupts.length === 0) return undefined;
if (interrupts == null || interrupts.length === 0) {
// check if there's a next task present
const next = threadHead?.next ?? [];
if (!next.length || error != null) return undefined;
return { when: "breakpoint" };
}
// Return only the current interrupt
return interrupts.at(-1) as Interrupt<InterruptType> | undefined;
+3 -3
View File
@@ -142,9 +142,9 @@ export interface AssistantGraph {
* An interrupt thrown inside a thread.
*/
export interface Interrupt<TValue = unknown> {
value: TValue;
when: "during";
resumable: boolean;
value?: TValue;
when: "during" | (string & {});
resumable?: boolean;
ns?: string[];
}