fix(atlas): use start-work session agent for continuation gating

Prefer the in-memory session agent set by /start-work when validating idle continuation eligibility, so stale message storage agent values do not block boulder continuation.
This commit is contained in:
YeonGyu-Kim
2026-02-27 13:37:41 +09:00
parent 15ad9442a4
commit 2eb7994163
2 changed files with 40 additions and 5 deletions
+5 -3
View File
@@ -1,6 +1,6 @@
import type { PluginInput } from "@opencode-ai/plugin"
import { getPlanProgress, readBoulderState } from "../../features/boulder-state"
import { subagentSessions } from "../../features/claude-code-session-state"
import { getSessionAgent, subagentSessions } from "../../features/claude-code-session-state"
import { log } from "../../shared/logger"
import { getAgentConfigKey } from "../../shared/agent-display-names"
import { HOOK_NAME } from "./hook-name"
@@ -97,8 +97,10 @@ export function createAtlasEventHandler(input: {
return
}
const sessionAgent = getSessionAgent(sessionID)
const lastAgent = await getLastAgentFromSession(sessionID, ctx.client)
const lastAgentKey = getAgentConfigKey(lastAgent ?? "")
const effectiveAgent = sessionAgent ?? lastAgent
const lastAgentKey = getAgentConfigKey(effectiveAgent ?? "")
const requiredAgent = getAgentConfigKey(boulderState.agent ?? "atlas")
const lastAgentMatchesRequired = lastAgentKey === requiredAgent
const boulderAgentDefaultsToAtlas = requiredAgent === "atlas"
@@ -108,7 +110,7 @@ export function createAtlasEventHandler(input: {
if (!agentMatches) {
log(`[${HOOK_NAME}] Skipped: last agent does not match boulder agent`, {
sessionID,
lastAgent: lastAgent ?? "unknown",
lastAgent: effectiveAgent ?? "unknown",
requiredAgent,
})
return