Skip to content

fix: match root planner by exact name in kickoff dedupe#113

Merged
poteto merged 2 commits into
cursor:mainfrom
Mubashirrrr:fix/kickoff-dedupe-prefix-collision
Jun 6, 2026
Merged

fix: match root planner by exact name in kickoff dedupe#113
poteto merged 2 commits into
cursor:mainfrom
Mubashirrrr:fix/kickoff-dedupe-prefix-collision

Conversation

@Mubashirrrr
Copy link
Copy Markdown
Contributor

@Mubashirrrr Mubashirrrr commented Jun 4, 2026

Problem

orchestrate kickoff is meant to be idempotent: if a recent root planner for the same goal is already running, it adopts that agent instead of spawning a duplicate. But the dedupe in findActiveRootPlanner adopts an active planner belonging to a different goal when one slug is a prefix of another.

Kicking off goal auth while a planner for goal auth-ui (agent named auth-ui-root) is active prints adopting <auth-ui agent> and attaches the new run to the wrong goal's planner. The intended auth run never starts, and the operator silently lands in an unrelated orchestration.

Root cause

The kickoff action names every root planner deterministically as `${rootSlug}-root` (cli/task.ts), but the dedupe scan matched with a bare prefix check:

if (!name.startsWith(rootSlug)) continue;

"auth-ui-root".startsWith("auth") is true, so a slug that is a prefix of another goal's slug collides. Non-root task agents use a different scheme (`${rootSlug}/${name}`), so only root planners are affected — but any two goals where one slug prefixes the other will cross-adopt.

Fix

Match the canonical planner name exactly. Since the name is fully deterministic, exact equality is both correct and the tightest possible check:

const rootPlannerName = `${rootSlug}-root`;
...
if (name !== rootPlannerName) continue;

Surgical, one-line behavioral change plus a clarifying comment. No other call sites or naming paths are touched.

Test

Added a regression test to __tests__/kickoff-dedupe.test.ts: an active refactor-ui-root planner must not be adopted when kicking off slug refactor (prefix overlap), asserting findActiveRootPlanner(...) returns null.

  • Fail-before: with the original startsWith check, the new test fails — findActiveRootPlanner returns the unrelated bc-refactor-ui agent instead of null.
  • Pass-after: with the exact-match fix, the new test passes.
  • Full suite green: bun test → 208 pass / 0 fail; tsc --noEmit clean.

Repro

import { findActiveRootPlanner } from "./cli/task.ts";

// Active planner for goal "auth-ui"; we kick off the distinct goal "auth".
const r = await findActiveRootPlanner(
  { async list() { return { items: [{
      agentId: "bc-authui",
      name: "auth-ui-root",
      createdAt: Date.now() - 1_000,
      latestRun: { id: "run-authui", status: "running" },
  }] }; } },
  "auth",
);
// before fix: r.agentId === "bc-authui"  (wrong goal adopted)
// after  fix: r === null                 (no match; a new planner is spawned)

Note

Low Risk
Small behavioral fix in kickoff idempotency with a targeted regression test; no auth or data-path changes.

Overview
Fixes kickoff dedupe so orchestrate kickoff only adopts a running root planner for the same goal, not a different goal whose slug happens to prefix yours.

findActiveRootPlanner now matches the canonical agent name `${rootSlug}-root` with equality instead of name.startsWith(rootSlug). That stops cases like kicking off auth from silently adopting an active auth-ui-root planner and skipping the intended run.

A regression test asserts that an active refactor-ui-root planner is not adopted when looking up slug refactor.

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

Mubashirrrr and others added 2 commits June 4, 2026 06:10
findActiveRootPlanner adopted any active cloud agent whose name merely
started with the kickoff slug (`name.startsWith(rootSlug)`). Because the
kickoff command names every root planner exactly `${rootSlug}-root`, a
slug that is a prefix of another goal's slug would wrongly adopt the
unrelated planner: kicking off goal `auth` while `auth-ui-root` is
active matched `"auth-ui-root".startsWith("auth")`, silently attaching a
fresh run to the wrong goal's planner instead of starting a new one.

Match the deterministic canonical name `${rootSlug}-root` exactly. Adds
a regression test asserting a prefix-only slug overlap does not adopt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@poteto
Copy link
Copy Markdown
Collaborator

poteto commented Jun 6, 2026

thanks!

@poteto poteto merged commit 91f6c6c into cursor:main Jun 6, 2026
1 check passed
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.

2 participants