fix(sisyphus-orchestrator): only trigger boulder continuation for orchestrator-sisyphus agent

This commit is contained in:
YeonGyu-Kim 2026-01-08 15:24:07 +09:00
parent 2d3894a860
commit 9481770a39
2 changed files with 42 additions and 0 deletions

View File

@ -517,6 +517,11 @@ describe("sisyphus-orchestrator hook", () => {
getMainSessionID: () => MAIN_SESSION_ID,
subagentSessions: new Set<string>(),
}))
setupMessageStorage(MAIN_SESSION_ID, "orchestrator-sisyphus")
})
afterEach(() => {
cleanupMessageStorage(MAIN_SESSION_ID)
})
test("should inject continuation when boulder has incomplete tasks", async () => {
@ -741,6 +746,38 @@ describe("sisyphus-orchestrator hook", () => {
expect(callArgs.body.parts[0].text).toContain("2 remaining")
})
test("should not inject when last agent is not orchestrator-sisyphus", async () => {
// #given - boulder state with incomplete plan, but last agent is NOT orchestrator-sisyphus
const planPath = join(TEST_DIR, "test-plan.md")
writeFileSync(planPath, "# Plan\n- [ ] Task 1\n- [ ] Task 2")
const state: BoulderState = {
active_plan: planPath,
started_at: "2026-01-02T10:00:00Z",
session_ids: [MAIN_SESSION_ID],
plan_name: "test-plan",
}
writeBoulderState(TEST_DIR, state)
// #given - last agent is NOT orchestrator-sisyphus
cleanupMessageStorage(MAIN_SESSION_ID)
setupMessageStorage(MAIN_SESSION_ID, "Sisyphus")
const mockInput = createMockPluginInput()
const hook = createSisyphusOrchestratorHook(mockInput)
// #when
await hook.handler({
event: {
type: "session.idle",
properties: { sessionID: MAIN_SESSION_ID },
},
})
// #then - should NOT call prompt because agent is not orchestrator-sisyphus
expect(mockInput._promptMock).not.toHaveBeenCalled()
})
test("should cleanup on session.deleted", async () => {
// #given - boulder state
const planPath = join(TEST_DIR, "test-plan.md")

View File

@ -422,6 +422,11 @@ export function createSisyphusOrchestratorHook(
return
}
if (!isCallerOrchestrator(sessionID)) {
log(`[${HOOK_NAME}] Skipped: last agent is not orchestrator-sisyphus`, { sessionID })
return
}
const progress = getPlanProgress(boulderState.active_plan)
if (progress.isComplete) {
log(`[${HOOK_NAME}] Boulder complete`, { sessionID, plan: boulderState.plan_name })