diff --git a/.changeset/whole-books-hear.md b/.changeset/whole-books-hear.md new file mode 100644 index 00000000..b04b5dea --- /dev/null +++ b/.changeset/whole-books-hear.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +fix(ollama): abort streaming requests when task is cancelled diff --git a/src/core/api/index.ts b/src/core/api/index.ts index a583ed54..fbc86c5f 100644 --- a/src/core/api/index.ts +++ b/src/core/api/index.ts @@ -51,6 +51,7 @@ export interface ApiHandler { createMessage(systemPrompt: string, messages: ClineStorageMessage[], tools?: ClineTool[], useResponseApi?: boolean): ApiStream getModel(): ApiHandlerModel getApiStreamUsage?(): Promise + abort?(): void } export interface ApiHandlerModel { diff --git a/src/core/api/providers/ollama.ts b/src/core/api/providers/ollama.ts index 29f94130..3f093878 100644 --- a/src/core/api/providers/ollama.ts +++ b/src/core/api/providers/ollama.ts @@ -121,4 +121,8 @@ export class OllamaHandler implements ApiHandler { }, } } + + abort(): void { + this.client?.abort() + } } diff --git a/src/core/task/index.ts b/src/core/task/index.ts index 6f0fa084..9ecf4235 100644 --- a/src/core/task/index.ts +++ b/src/core/task/index.ts @@ -2907,6 +2907,7 @@ export class Task { ) if (this.taskState.abort) { + this.api.abort?.() if (!this.taskState.abandoned) { // only need to gracefully abort if this instance isn't abandoned (sometimes openrouter stream hangs, in which case this would affect future instances of cline) await abortStream("user_cancelled")