Merge pull request #2151 from ualtinok/fix/agent-usage-reminder-subagent-exclusion
[Bug]: agent-usage-reminder hook sends circular reminders to explore/librarian subagents
This commit is contained in:
commit
d39b3aa9b7
@ -6,6 +6,8 @@ import {
|
|||||||
} from "./storage";
|
} from "./storage";
|
||||||
import { TARGET_TOOLS, AGENT_TOOLS, REMINDER_MESSAGE } from "./constants";
|
import { TARGET_TOOLS, AGENT_TOOLS, REMINDER_MESSAGE } from "./constants";
|
||||||
import type { AgentUsageState } from "./types";
|
import type { AgentUsageState } from "./types";
|
||||||
|
import { getSessionAgent } from "../../features/claude-code-session-state";
|
||||||
|
import { getAgentConfigKey } from "../../shared/agent-display-names";
|
||||||
|
|
||||||
interface ToolExecuteInput {
|
interface ToolExecuteInput {
|
||||||
tool: string;
|
tool: string;
|
||||||
@ -26,6 +28,23 @@ 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) {
|
export function createAgentUsageReminderHook(_ctx: PluginInput) {
|
||||||
const sessionStates = new Map<string, AgentUsageState>();
|
const sessionStates = new Map<string, AgentUsageState>();
|
||||||
|
|
||||||
@ -60,6 +79,12 @@ export function createAgentUsageReminderHook(_ctx: PluginInput) {
|
|||||||
output: ToolExecuteOutput,
|
output: ToolExecuteOutput,
|
||||||
) => {
|
) => {
|
||||||
const { tool, sessionID } = input;
|
const { tool, sessionID } = input;
|
||||||
|
|
||||||
|
const agent = getSessionAgent(sessionID);
|
||||||
|
if (agent && !isOrchestratorAgent(agent)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const toolLower = tool.toLowerCase();
|
const toolLower = tool.toLowerCase();
|
||||||
|
|
||||||
if (AGENT_TOOLS.has(toolLower)) {
|
if (AGENT_TOOLS.has(toolLower)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user