Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,30 @@ describe("kickoff dedupe", () => {
expect(active).toBeNull();
});

test("does not adopt a planner whose slug only shares a prefix", async () => {
const now = Date.parse("2026-05-01T16:00:00.000Z");
const active = await findActiveRootPlanner(
{
async list() {
return {
items: [
{
agentId: "bc-refactor-ui",
name: "refactor-ui-root",
createdAt: now - 1_000,
latestRun: { id: "run-refactor-ui", status: "running" },
},
],
};
},
},
"refactor",
now
);

expect(active).toBeNull();
});

test("falls back to listRuns when list omits latest run", async () => {
const now = Date.parse("2026-05-01T16:00:00.000Z");
const active = await findActiveRootPlanner(
Expand Down
5 changes: 4 additions & 1 deletion orchestrate/skills/orchestrate/scripts/cli/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,13 @@ export async function findActiveRootPlanner(
nowMs: number = Date.now()
): Promise<ActiveRootPlanner | null> {
const list = await agentApi.list({ runtime: "cloud", limit: 50 });
// Exact match, not startsWith: a prefix slug would otherwise adopt another
// goal's `<slug>-root` planner (e.g. "auth" adopting "auth-ui-root").
const rootPlannerName = `${rootSlug}-root`;
for (const item of listItems(list)) {
const name = stringField(item, "name");
if (!name) continue;
if (!name.startsWith(rootSlug)) continue;
if (name !== rootPlannerName) continue;
const createdAt = timeMs(field(item, "createdAt"));
if (createdAt === null || nowMs - createdAt > MAX_BOOT_MS) continue;
const agentId =
Expand Down