fix(background-agent): abort session on task completion to prevent zombie attach processes
This commit is contained in:
parent
e8cdab8871
commit
3e9a0ef9aa
@ -982,6 +982,41 @@ describe("BackgroundManager.tryCompleteTask", () => {
|
|||||||
expect(task.status).toBe("completed")
|
expect(task.status).toBe("completed")
|
||||||
expect(concurrencyManager.getCount(concurrencyKey)).toBe(0)
|
expect(concurrencyManager.getCount(concurrencyKey)).toBe(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("should abort session on completion", async () => {
|
||||||
|
// #given
|
||||||
|
const abortedSessionIDs: string[] = []
|
||||||
|
const client = {
|
||||||
|
session: {
|
||||||
|
prompt: async () => ({}),
|
||||||
|
abort: async (args: { path: { id: string } }) => {
|
||||||
|
abortedSessionIDs.push(args.path.id)
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
manager.shutdown()
|
||||||
|
manager = new BackgroundManager({ client, directory: tmpdir() } as unknown as PluginInput)
|
||||||
|
stubNotifyParentSession(manager)
|
||||||
|
|
||||||
|
const task: BackgroundTask = {
|
||||||
|
id: "task-1",
|
||||||
|
sessionID: "session-1",
|
||||||
|
parentSessionID: "session-parent",
|
||||||
|
parentMessageID: "msg-1",
|
||||||
|
description: "test task",
|
||||||
|
prompt: "test",
|
||||||
|
agent: "explore",
|
||||||
|
status: "running",
|
||||||
|
startedAt: new Date(),
|
||||||
|
}
|
||||||
|
|
||||||
|
// #when
|
||||||
|
await tryCompleteTaskForTest(manager, task)
|
||||||
|
|
||||||
|
// #then
|
||||||
|
expect(abortedSessionIDs).toEqual(["session-1"])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("BackgroundManager.trackTask", () => {
|
describe("BackgroundManager.trackTask", () => {
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user