diff --git a/src/hooks/agent-usage-reminder/hook.ts b/src/hooks/agent-usage-reminder/hook.ts index ef2a7b3d9..49e32ce13 100644 --- a/src/hooks/agent-usage-reminder/hook.ts +++ b/src/hooks/agent-usage-reminder/hook.ts @@ -6,8 +6,7 @@ import { } from "./storage"; import { TARGET_TOOLS, AGENT_TOOLS, REMINDER_MESSAGE } from "./constants"; import type { AgentUsageState } from "./types"; -import { getSessionAgent } from "../../features/claude-code-session-state"; -import { getAgentConfigKey } from "../../shared/agent-display-names"; +import { isOrchestratorAgent } from "../../shared/orchestrator-agents"; interface ToolExecuteInput { tool: string; @@ -28,23 +27,6 @@ interface EventInput { }; } -/** - * Only orchestrator agents should receive usage reminders. - * Subagents (explore, librarian, oracle, etc.) are the targets of delegation, - * so reminding them to delegate to themselves is counterproductive. - */ -const ORCHESTRATOR_AGENTS = new Set([ - "sisyphus", - "sisyphus-junior", - "atlas", - "hephaestus", - "prometheus", -]); - -function isOrchestratorAgent(agentName: string): boolean { - return ORCHESTRATOR_AGENTS.has(getAgentConfigKey(agentName)); -} - export function createAgentUsageReminderHook(_ctx: PluginInput) { const sessionStates = new Map(); @@ -80,8 +62,7 @@ export function createAgentUsageReminderHook(_ctx: PluginInput) { ) => { const { tool, sessionID } = input; - const agent = getSessionAgent(sessionID); - if (agent && !isOrchestratorAgent(agent)) { + if (!isOrchestratorAgent(sessionID)) { return; } diff --git a/src/hooks/category-skill-reminder/hook.ts b/src/hooks/category-skill-reminder/hook.ts index a89d182b0..9e75b3417 100644 --- a/src/hooks/category-skill-reminder/hook.ts +++ b/src/hooks/category-skill-reminder/hook.ts @@ -1,20 +1,9 @@ import type { PluginInput } from "@opencode-ai/plugin" import type { AvailableSkill } from "../../agents/dynamic-agent-prompt-builder" -import { getSessionAgent } from "../../features/claude-code-session-state" import { log } from "../../shared" -import { getAgentConfigKey } from "../../shared/agent-display-names" +import { isOrchestratorAgent } from "../../shared/orchestrator-agents" import { buildReminderMessage } from "./formatter" -/** - * Target agents that should receive category+skill reminders. - * These are orchestrator agents that delegate work to specialized agents. - */ -const TARGET_AGENTS = new Set([ - "sisyphus", - "sisyphus-junior", - "atlas", -]) - /** * Tools that indicate the agent is doing work that could potentially be delegated. * When these tools are used, we remind the agent about the category+skill system. @@ -73,22 +62,11 @@ export function createCategorySkillReminderHook( return sessionStates.get(sessionID)! } - function isTargetAgent(sessionID: string, inputAgent?: string): boolean { - const agent = getSessionAgent(sessionID) ?? inputAgent - if (!agent) return false - const agentKey = getAgentConfigKey(agent) - return ( - TARGET_AGENTS.has(agentKey) || - agentKey.includes("sisyphus") || - agentKey.includes("atlas") - ) - } - const toolExecuteAfter = async (input: ToolExecuteInput, output: ToolExecuteOutput) => { const { tool, sessionID } = input const toolLower = tool.toLowerCase() - if (!isTargetAgent(sessionID, input.agent)) { + if (!isOrchestratorAgent(sessionID, input.agent)) { return } diff --git a/src/shared/index.ts b/src/shared/index.ts index 09187602f..d3bc0605f 100644 --- a/src/shared/index.ts +++ b/src/shared/index.ts @@ -32,6 +32,7 @@ export * from "./session-cursor" export * from "./shell-env" export * from "./system-directive" export * from "./agent-tool-restrictions" +export * from "./orchestrator-agents" export * from "./model-requirements" export * from "./model-resolver" export { normalizeFallbackModels } from "./model-resolver" diff --git a/src/shared/orchestrator-agents.ts b/src/shared/orchestrator-agents.ts new file mode 100644 index 000000000..ba8f2952d --- /dev/null +++ b/src/shared/orchestrator-agents.ts @@ -0,0 +1,21 @@ +import { getSessionAgent } from "../features/claude-code-session-state" +import { getAgentConfigKey } from "./agent-display-names" + +export const ORCHESTRATOR_AGENTS = new Set([ + "sisyphus", + "sisyphus-junior", + "atlas", + "hephaestus", + "prometheus", +]) + +export function isOrchestratorAgent(sessionID: string, inputAgent?: string): boolean { + const agent = getSessionAgent(sessionID) ?? inputAgent + if (!agent) return true + const agentKey = getAgentConfigKey(agent) + return ( + ORCHESTRATOR_AGENTS.has(agentKey) || + agentKey.includes("sisyphus") || + agentKey.includes("atlas") + ) +}