Skip to content

Commit 7b3c2b2

Browse files
Merge pull request #141 from Jerrynh770/main
fix: pass abortSignal to streamText to enable stop streaming
2 parents 6ba0e8c + d7e7411 commit 7b3c2b2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/server.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class Chat extends AIChatAgent<Env> {
3434
*/
3535
async onChatMessage(
3636
onFinish: StreamTextOnFinishCallback<ToolSet>,
37-
_options?: { abortSignal?: AbortSignal }
37+
options?: { abortSignal?: AbortSignal }
3838
) {
3939
// const mcpConnection = await this.mcp.connect(
4040
// "https://path-to-mcp-server/sse"
@@ -76,7 +76,8 @@ If the user asks to schedule a task, use the schedule tool to schedule the task.
7676
onFinish: onFinish as unknown as StreamTextOnFinishCallback<
7777
typeof allTools
7878
>,
79-
stopWhen: stepCountIs(10)
79+
stopWhen: stepCountIs(10),
80+
abortSignal: options?.abortSignal
8081
});
8182

8283
writer.merge(result.toUIMessageStream());

0 commit comments

Comments
 (0)