Skip to content

orchestrate: kill-tree descends into handed-off subplanner branches like crawl - #647

Open
deanrie wants to merge 1 commit into
cursor:mainfrom
deanrie:orchestrate/kill-tree-handed-off
Open

deanrie wants to merge 1 commit into
cursor:mainfrom
deanrie:orchestrate/kill-tree-handed-off

Conversation

@deanrie

@deanrie deanrie commented Oct 16, 2026

Copy link
Copy Markdown

Summary

Fixes #641. crawlBranch (used by crawl) descends into a subplanner branch when its status is running or handed-off; collectRunningAgentsInTree (used by kill-tree via filterVictimsToSubtree) descended only on running. A subplanner whose own run has ended is handed-off in the parent's state.json, but the state.json on its branch can still hold running rows with agentId/runId (a verifier or respawn it started before returning, workers in flight). crawl listed those agents; kill-tree printed nothing to kill and left them running, while the doc comment on collectRunningAgentsInTree and the kill-tree help text both say the two walk the tree the same way.

Both walkers now share one predicate, descendsIntoSubplanner(t) (running or handed-off subplanner), so they cannot drift apart again. No other behaviour changes: kill-tree still only collects tasks that are running with both ids; it just also looks under handed-off subplanners to find them.

If the orchestrate owners prefer the opposite contract (skip handed-off branches on purpose), the same helper is the one place to say so, and the help text and crawl output should then say it too.

Verification

  • New __tests__/kill-tree-handed-off.test.ts builds a temp repo with origin/<branch> refs for a root planner (subplanner row handed-off) and the subplanner's own branch (worker row running), and asserts crawlBranch prints the worker and collectRunningAgentsInTree returns it. Fails on main (0 collected), passes with the fix.
  • bun test in orchestrate/skills/orchestrate/scripts: 211 tests, 0 fail; bun run typecheck clean.

…ike crawl

crawlBranch followed subplanners whose status is running or handed-off;
collectRunningAgentsInTree (kill-tree) followed only running ones, so a
verifier or worker still running under a handed-off subplanner was listed
by crawl but reported as "nothing to kill". Both walkers now use one
predicate, descendsIntoSubplanner, so they cannot drift again. Test builds
a two-branch repo with a handed-off subplanner and a running child and
asserts crawl and kill-tree both see it.

Fixes cursor#641.
@deanrie

deanrie commented Oct 16, 2026

Copy link
Copy Markdown
Author

Hey all, for the record: #645 (Ehsan-hash) was opened about an hour before this one and fixes the same handed-off descent for #641, and additionally carries ancestor links through finished planners so agent-scoped kill-tree selection keeps working, with broader fixtures. If the orchestrate owners prefer that one, this can be closed in its favour; the one piece worth keeping from here is the shared descendsIntoSubplanner predicate, so crawlBranch and the kill-tree walker use a single definition and cannot drift apart again. Happy to rebase that onto #645 as a follow-up instead.

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