fix(start-work): gracefully handle missing Atlas agent (fixes #2132)
This commit is contained in:
@@ -11,12 +11,23 @@ export function getMainSessionID(): string | undefined {
|
||||
return _mainSessionID
|
||||
}
|
||||
|
||||
const registeredAgentNames = new Set<string>()
|
||||
|
||||
export function registerAgentName(name: string): void {
|
||||
registeredAgentNames.add(name.toLowerCase())
|
||||
}
|
||||
|
||||
export function isAgentRegistered(name: string): boolean {
|
||||
return registeredAgentNames.has(name.toLowerCase())
|
||||
}
|
||||
|
||||
/** @internal For testing only */
|
||||
export function _resetForTesting(): void {
|
||||
_mainSessionID = undefined
|
||||
subagentSessions.clear()
|
||||
syncSubagentSessions.clear()
|
||||
sessionAgentMap.clear()
|
||||
registeredAgentNames.clear()
|
||||
}
|
||||
|
||||
const sessionAgentMap = new Map<string, string>()
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from "../../features/boulder-state"
|
||||
import { log } from "../../shared/logger"
|
||||
import { getAgentDisplayName } from "../../shared/agent-display-names"
|
||||
import { updateSessionAgent } from "../../features/claude-code-session-state"
|
||||
import { updateSessionAgent, isAgentRegistered } from "../../features/claude-code-session-state"
|
||||
import { detectWorktreePath } from "./worktree-detector"
|
||||
import { parseUserRequest } from "./parse-user-request"
|
||||
|
||||
@@ -80,9 +80,14 @@ export function createStartWorkHook(ctx: PluginInput) {
|
||||
if (!promptText.includes("<session-context>")) return
|
||||
|
||||
log(`[${HOOK_NAME}] Processing start-work command`, { sessionID: input.sessionID })
|
||||
updateSessionAgent(input.sessionID, "atlas")
|
||||
if (output.message) {
|
||||
output.message["agent"] = getAgentDisplayName("atlas")
|
||||
const atlasDisplayName = getAgentDisplayName("atlas")
|
||||
if (isAgentRegistered("atlas") || isAgentRegistered(atlasDisplayName)) {
|
||||
updateSessionAgent(input.sessionID, "atlas")
|
||||
if (output.message) {
|
||||
output.message["agent"] = atlasDisplayName
|
||||
}
|
||||
} else {
|
||||
log(`[${HOOK_NAME}] Atlas agent not available, continuing with current agent`, { sessionID: input.sessionID })
|
||||
}
|
||||
|
||||
const existingState = readBoulderState(ctx.directory)
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { OhMyOpenCodeConfig } from "../config";
|
||||
import { log, migrateAgentConfig } from "../shared";
|
||||
import { AGENT_NAME_MAP } from "../shared/migration";
|
||||
import { getAgentDisplayName } from "../shared/agent-display-names";
|
||||
import { registerAgentName } from "../features/claude-code-session-state";
|
||||
import {
|
||||
discoverConfigSourceSkills,
|
||||
discoverGlobalAgentsSkills,
|
||||
@@ -292,6 +293,9 @@ export async function applyAgentConfig(params: {
|
||||
}
|
||||
|
||||
const agentResult = params.config.agent as Record<string, unknown>;
|
||||
for (const name of Object.keys(agentResult)) {
|
||||
registerAgentName(name);
|
||||
}
|
||||
log("[config-handler] agents loaded", { agentKeys: Object.keys(agentResult) });
|
||||
return agentResult;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user