diff --git a/server/src/__tests__/issue-onboarding-first-task-routes.test.ts b/server/src/__tests__/issue-onboarding-first-task-routes.test.ts index 0ae5a48a5e3..87b590e517c 100644 --- a/server/src/__tests__/issue-onboarding-first-task-routes.test.ts +++ b/server/src/__tests__/issue-onboarding-first-task-routes.test.ts @@ -342,6 +342,25 @@ describeEmbeddedPostgres("issue create onboarding first-task routes", () => { expect(mockAdapterExecute).not.toHaveBeenCalled(); }); + it.each(["done", "cancelled"])("does not queue an assignment wake for an issue created already %s", async (status) => { + const companyId = await seedCompany(); + const agentId = await seedAgent(companyId); + const app = createApp(); + + await request(app) + .post(`/api/companies/${companyId}/issues`) + .send({ title: "Historical record", status, assigneeAgentId: agentId }) + .expect(201); + + await drainHeartbeatRunsToQuiescence(db, heartbeatService(db)); + const wakeups = await db + .select() + .from(agentWakeupRequests) + .where(eq(agentWakeupRequests.companyId, companyId)); + expect(wakeups).toHaveLength(0); + expect(mockAdapterExecute).not.toHaveBeenCalled(); + }); + it("still queues an assignment wake for an ordinary assigned issue", async () => { const companyId = await seedCompany(); const agentId = await seedAgent(companyId); diff --git a/server/src/routes/issues.ts b/server/src/routes/issues.ts index 73c7c754ca5..9d7fee46aec 100644 --- a/server/src/routes/issues.ts +++ b/server/src/routes/issues.ts @@ -13319,9 +13319,11 @@ export function issueRoutes( // Do not auto-wake the onboarding first task. Nothing should run and no // token should be spent until the user types: the greeting is posted above // (deterministic, no LLM) and the user's first comment wakes the assignee - // through the normal comment path. Every other create path keeps its wake. + // through the normal comment path. A task created already done or + // cancelled is a record, not work: like restoring an assignee on closed + // work, it must not wake the assignee. Every other create keeps its wake. - if (!isOnboardingFirstTask) { + if (!isOnboardingFirstTask && !isClosedIssueStatus(issue.status)) { void queueIssueAssignmentWakeup({ heartbeat, issue,