mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
core: fix session cancellation cleanup to prevent memory leaks in task tool
This commit is contained in:
parent
47e0e0ae1f
commit
eea9346e97
1 changed files with 5 additions and 2 deletions
|
|
@ -7,6 +7,7 @@ import { MessageV2 } from "../session/message-v2"
|
|||
import { Identifier } from "../id/id"
|
||||
import { Agent } from "../agent/agent"
|
||||
import { SessionPrompt } from "../session/prompt"
|
||||
import { defer } from "@/util/defer"
|
||||
|
||||
export const TaskTool = Tool.define("task", async () => {
|
||||
const agents = await Agent.list().then((x) => x.filter((a) => a.mode !== "primary"))
|
||||
|
|
@ -61,9 +62,11 @@ export const TaskTool = Tool.define("task", async () => {
|
|||
providerID: msg.info.providerID,
|
||||
}
|
||||
|
||||
ctx.abort.addEventListener("abort", () => {
|
||||
function cancel() {
|
||||
SessionPrompt.cancel(session.id)
|
||||
})
|
||||
}
|
||||
ctx.abort.addEventListener("abort", cancel)
|
||||
using _ = defer(() => ctx.abort.removeEventListener("abort", cancel))
|
||||
const promptParts = await SessionPrompt.resolvePromptParts(params.prompt)
|
||||
const result = await SessionPrompt.prompt({
|
||||
messageID,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue