fix(background-agent): cancel all nested descendant tasks recursively (#107)
Previously, background_cancel(all=true) only cancelled direct child tasks, leaving grandchildren and deeper nested tasks uncancelled. This caused background agents to continue running even when their parent session was cancelled. Changes: - Added getAllDescendantTasks() method to BackgroundTaskManager for recursive task collection - Updated background_cancel to use getAllDescendantTasks instead of getTasksByParentSession - Added comprehensive test coverage for nested task cancellation scenarios 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
This commit is contained in:
@@ -275,7 +275,7 @@ export function createBackgroundCancel(manager: BackgroundManager, client: Openc
|
||||
}
|
||||
|
||||
if (cancelAll) {
|
||||
const tasks = manager.getTasksByParentSession(toolContext.sessionID)
|
||||
const tasks = manager.getAllDescendantTasks(toolContext.sessionID)
|
||||
const runningTasks = tasks.filter(t => t.status === "running")
|
||||
|
||||
if (runningTasks.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user