diff --git a/src/costrict/agents/strictPlan.ts b/src/costrict/agents/strictPlan.ts index 08c716dc4..6ddfd6b5f 100644 --- a/src/costrict/agents/strictPlan.ts +++ b/src/costrict/agents/strictPlan.ts @@ -235,5 +235,8 @@ export const STRICT_PLAN_AGENT: BuiltInAgentDefinition = { baseDir: 'built-in', model: 'inherit', omitClaudeMd: false, + // 通过斜杠命令从主线程启动时,使 resolveAgentTools 跳过 filterToolsForAgent, + // 从而保留主线程完整工具集(包括 Agent 工具)。 + isMainThread: true, getSystemPrompt: () => getStrictPlanSystemPrompt(), } diff --git a/src/tools/AgentTool/agentToolUtils.ts b/src/tools/AgentTool/agentToolUtils.ts index 084ac6a85..c14c48214 100644 --- a/src/tools/AgentTool/agentToolUtils.ts +++ b/src/tools/AgentTool/agentToolUtils.ts @@ -122,7 +122,7 @@ export function filterToolsForAgent({ export function resolveAgentTools( agentDefinition: Pick< AgentDefinition, - 'tools' | 'disallowedTools' | 'source' | 'permissionMode' + 'tools' | 'disallowedTools' | 'source' | 'permissionMode' | 'isMainThread' >, availableTools: Tools, isAsync = false, @@ -133,11 +133,15 @@ export function resolveAgentTools( disallowedTools, source, permissionMode, + isMainThread: agentIsMainThread, } = agentDefinition - // When isMainThread is true, skip filterToolsForAgent entirely — the main - // thread's tool pool is already properly assembled by useMergedTools(), so + // Allow the agent definition itself to declare isMainThread=true, + // which takes precedence over the isMainThread parameter. + const effectiveIsMainThread = agentIsMainThread ?? isMainThread + // When effectiveIsMainThread is true, skip filterToolsForAgent entirely — the + // main thread's tool pool is already properly assembled by useMergedTools(), so // the sub-agent disallow lists shouldn't apply. - const filteredAvailableTools = isMainThread + const filteredAvailableTools = effectiveIsMainThread ? availableTools : filterToolsForAgent({ tools: availableTools, @@ -195,7 +199,7 @@ export function resolveAgentTools( } // For sub-agents, Agent is excluded by filterToolsForAgent — mark the spec // valid for allowedAgentTypes tracking but skip tool resolution. - if (!isMainThread) { + if (!effectiveIsMainThread) { validTools.push(toolSpec) continue } diff --git a/src/tools/AgentTool/loadAgentsDir.ts b/src/tools/AgentTool/loadAgentsDir.ts index cb4dc35e2..5336f45ea 100644 --- a/src/tools/AgentTool/loadAgentsDir.ts +++ b/src/tools/AgentTool/loadAgentsDir.ts @@ -130,6 +130,10 @@ export type BaseAgentDefinition = { * full CLAUDE.md and interprets their output. Saves ~5-15 Gtok/week across * 34M+ Explore spawns. Kill-switch: tengu_slim_subagent_claudemd. */ omitClaudeMd?: boolean + /** When true, resolveAgentTools skips filterToolsForAgent so the agent + * receives the full main-thread tool pool (including Agent tool). + * Use for agents launched directly via slash command from the main thread. */ + isMainThread?: boolean } // Built-in agents - dynamic prompts only, no static systemPrompt field