Skip to content

Commit 556e19d

Browse files
committed
feat: enable aborting run for langgraph platform based graphs
1 parent 3ea9945 commit 556e19d

File tree

1 file changed

+8
-1
lines changed
  • typescript-sdk/integrations/langgraph/src

1 file changed

+8
-1
lines changed

typescript-sdk/integrations/langgraph/src/agent.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export class LangGraphAgent extends AbstractAgent {
126126
subscriber: Subscriber<ProcessedEvents>;
127127
constantSchemaKeys: string[] = DEFAULT_SCHEMA_KEYS;
128128
config: LangGraphAgentConfig;
129+
abortController = new AbortController();
129130

130131
constructor(config: LangGraphAgentConfig) {
131132
super(config);
@@ -160,6 +161,10 @@ export class LangGraphAgent extends AbstractAgent {
160161
});
161162
}
162163

164+
abortRun() {
165+
this.abortController.abort();
166+
}
167+
163168
async runAgentStream(input: RunAgentExtendedInput, subscriber: Subscriber<ProcessedEvents>) {
164169
this.activeRun = {
165170
id: input.runId,
@@ -213,6 +218,7 @@ export class LangGraphAgent extends AbstractAgent {
213218
// @ts-ignore
214219
checkpointId: fork.checkpoint.checkpoint_id!,
215220
streamMode,
221+
signal: this.abortController.signal,
216222
};
217223
return {
218224
streamResponse: this.client.runs.stream(threadId, this.assistant.assistant_id, payload),
@@ -331,7 +337,8 @@ export class LangGraphAgent extends AbstractAgent {
331337
context: {
332338
...context,
333339
...(payloadConfig?.configurable ?? {}),
334-
}
340+
},
341+
signal: this.abortController.signal,
335342
};
336343

337344
// If there are still outstanding unresolved interrupts, we must force resolution of them before moving forward

0 commit comments

Comments
 (0)