fix(start-work): always hand off to atlas regardless of current session agent (#3155)
/start-work is the "execute this plan with atlas" command. Previously, if the user's current session agent was sisyphus (or any non-prometheus/non-atlas agent), the hook would keep that agent instead of switching to atlas. This caused sisyphus to execute the plan. Fix: unconditionally select atlas (when registered) or sisyphus (fallback). The current session agent is irrelevant to /start-work's intent. Adds regression test: running /start-work from a sisyphus session must always hand off to atlas when atlas is available.
This commit is contained in:
@@ -456,6 +456,27 @@ You are starting a Sisyphus work session.
|
||||
expect(output.message.agent).toBe(getAgentListDisplayName("atlas"))
|
||||
})
|
||||
|
||||
test("should switch to Atlas even when current session is Sisyphus (regression: #3155)", async () => {
|
||||
// given: user runs /start-work while in a Sisyphus session
|
||||
// atlas is registered, so /start-work must always hand off to atlas
|
||||
sessionState.updateSessionAgent("ses-sisyphus-to-atlas", "sisyphus")
|
||||
|
||||
const hook = createStartWorkHook(createMockPluginInput())
|
||||
const output = {
|
||||
message: {} as Record<string, unknown>,
|
||||
parts: [{ type: "text", text: createStartWorkPrompt() }],
|
||||
}
|
||||
|
||||
await hook["chat.message"](
|
||||
{ sessionID: "ses-sisyphus-to-atlas" },
|
||||
output
|
||||
)
|
||||
|
||||
// atlas is registered in beforeEach, so it must be selected
|
||||
expect(output.message.agent).toBe(getAgentListDisplayName("atlas"))
|
||||
expect(sessionState.getSessionAgent("ses-sisyphus-to-atlas")).toBe("atlas")
|
||||
})
|
||||
|
||||
test("should keep the current agent when Atlas is unavailable", async () => {
|
||||
// given
|
||||
sessionState._resetForTesting()
|
||||
|
||||
@@ -12,12 +12,10 @@ import {
|
||||
} from "../../features/boulder-state"
|
||||
import { log } from "../../shared/logger"
|
||||
import {
|
||||
getAgentConfigKey,
|
||||
getAgentDisplayName,
|
||||
getAgentListDisplayName,
|
||||
} from "../../shared/agent-display-names"
|
||||
import {
|
||||
getSessionAgent,
|
||||
isAgentRegistered,
|
||||
updateSessionAgent,
|
||||
} from "../../features/claude-code-session-state"
|
||||
@@ -84,18 +82,9 @@ export function createStartWorkHook(ctx: PluginInput) {
|
||||
}
|
||||
|
||||
log(`[${HOOK_NAME}] Processing start-work command`, { sessionID: input.sessionID })
|
||||
const currentSessionAgent = getSessionAgent(input.sessionID)
|
||||
const currentSessionAgentKey = currentSessionAgent
|
||||
? getAgentConfigKey(currentSessionAgent)
|
||||
: undefined
|
||||
const activeAgent = currentSessionAgent
|
||||
&& currentSessionAgentKey
|
||||
&& currentSessionAgentKey !== "prometheus"
|
||||
&& currentSessionAgentKey !== "atlas"
|
||||
? currentSessionAgent
|
||||
: isAgentRegistered("atlas")
|
||||
? "atlas"
|
||||
: "sisyphus"
|
||||
const activeAgent = isAgentRegistered("atlas")
|
||||
? "atlas"
|
||||
: "sisyphus"
|
||||
const activeAgentDisplayName = activeAgent === "atlas"
|
||||
? getAgentListDisplayName(activeAgent)
|
||||
: getAgentDisplayName(activeAgent)
|
||||
|
||||
Reference in New Issue
Block a user