Skip to content

fix(orchestrate): find handed-off planner descendants - #645

Open
Ehsan-hash wants to merge 2 commits into
cursor:mainfrom
Ehsan-hash:fix/kill-tree-handed-off
Open

Ehsan-hash wants to merge 2 commits into
cursor:mainfrom
Ehsan-hash:fix/kill-tree-handed-off

Conversation

@Ehsan-hash

@Ehsan-hash Ehsan-hash commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #641.

Why

crawl finds running children beneath handed-off planners, but kill-tree skips those branches and can report that nothing is running. Agent-specific scopes also lose the parent link through a finished planner.

What changed

  • Traverse handed-off subplanners when collecting running agents.
  • Retain actual parent links for scoped selection, with a cycle guard.
  • Add local Git fixtures covering root, planner, sibling, unknown, and cyclic scopes.

Scope

Only running agents become cancellation targets. Existing CLI confirmation and direct parent-only filtering remain intact.

Blast Radius

This changes discovery and scoped selection for kill-tree. The SDK cancellation call and authentication checks are unchanged.

Verification

  • npx --yes bun@1.4.2 test: 211 tests pass in the orchestrate scripts directory. The regression fails on the original source.
  • Typecheck, Biome checks, and the plugin validator pass. Independent read-only review covers the complete change.
  • Actual local crawl and kill-tree --no-fetch previews use synthetic Git refs. Whole-tree and scoped previews find the child and still require -y. No live cloud cancellation was performed.

AI assistance: Codex implementation and independent review.


Note

Medium Risk
Changes which agents kill-tree discovers and cancels; behavior is narrower in some scopes but broader under handed-off planners, with no change to SDK auth or cancellation APIs.

Overview
Fixes kill-tree agent discovery so it matches crawl: running workers under handed-off subplanners are included, and scoped --agent-id selection still reaches those descendants when the planner link is no longer a direct parent.

collectRunningAgentsInTree now descends into handed-off subplanner branches (not only running), records parent links while walking, and attaches optional ancestorAgentIds on each victim with cycle protection. filterVictimsToSubtree keeps the existing direct parent-child walk but also selects victims whose resolved ancestors include the scope root—so scoping by a finished planner or its upstream parent still targets nested running agents.

Adds tree-traversal tests with a temporary Git remote fixture covering nested branches, completed tasks, unknown agents, and cyclic parent metadata.

Reviewed by Cursor Bugbot for commit 14f8155. Bugbot is set up for automated code reviews on this repo. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

orchestrate: kill-tree skips running agents under handed-off subplanner branches, diverging from crawl and from its own help text

1 participant