Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion typescript-sdk/integrations/langgraph/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export class LangGraphAgent extends AbstractAgent {
subscriber: Subscriber<ProcessedEvents>;
constantSchemaKeys: string[] = DEFAULT_SCHEMA_KEYS;
config: LangGraphAgentConfig;
abortController = new AbortController();

constructor(config: LangGraphAgentConfig) {
super(config);
Expand Down Expand Up @@ -160,6 +161,10 @@ export class LangGraphAgent extends AbstractAgent {
});
}

abortRun() {
this.abortController.abort();
}

async runAgentStream(input: RunAgentExtendedInput, subscriber: Subscriber<ProcessedEvents>) {
this.activeRun = {
id: input.runId,
Expand Down Expand Up @@ -213,6 +218,7 @@ export class LangGraphAgent extends AbstractAgent {
// @ts-ignore
checkpointId: fork.checkpoint.checkpoint_id!,
streamMode,
signal: this.abortController.signal,
};
return {
streamResponse: this.client.runs.stream(threadId, this.assistant.assistant_id, payload),
Expand Down Expand Up @@ -331,7 +337,8 @@ export class LangGraphAgent extends AbstractAgent {
context: {
...context,
...(payloadConfig?.configurable ?? {}),
}
},
signal: this.abortController.signal,
};

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