mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
feat: 将 Agents/Teams 工具纳入 Tool Search 按需发现
将 TeamCreate、TeamDelete、SendMessage 从 CORE_TOOLS 移除, 使其成为 deferred 工具,通过 ToolSearch 按需发现以减少 context token。 swarm 模式下 SendMessage 保持 always loaded,TeamCreate/TeamDelete 在 swarm 未启用时调用返回启用提示。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -553,7 +553,8 @@ async function handlePlanRejection(
|
||||
export const SendMessageTool: Tool<InputSchema, SendMessageToolOutput> =
|
||||
buildTool({
|
||||
name: SEND_MESSAGE_TOOL_NAME,
|
||||
searchHint: 'send messages to agent teammates (swarm protocol)',
|
||||
searchHint:
|
||||
'send message to teammate agent, broadcast, inter-agent communication, swarm messaging, agent coordination',
|
||||
maxResultSizeChars: 100_000,
|
||||
|
||||
userFacingName() {
|
||||
@@ -564,9 +565,10 @@ export const SendMessageTool: Tool<InputSchema, SendMessageToolOutput> =
|
||||
return inputSchema()
|
||||
},
|
||||
shouldDefer: true,
|
||||
alwaysLoad: isAgentSwarmsEnabled(),
|
||||
|
||||
isEnabled() {
|
||||
return isAgentSwarmsEnabled()
|
||||
return true
|
||||
},
|
||||
|
||||
isReadOnly(input) {
|
||||
|
||||
@@ -73,7 +73,8 @@ function generateUniqueTeamName(providedName: string): string {
|
||||
|
||||
export const TeamCreateTool: Tool<InputSchema, Output> = buildTool({
|
||||
name: TEAM_CREATE_TOOL_NAME,
|
||||
searchHint: 'create a multi-agent swarm team',
|
||||
searchHint:
|
||||
'create multi-agent swarm team, collaborate, parallel agents, task distribution, agent coordination, team management',
|
||||
maxResultSizeChars: 100_000,
|
||||
shouldDefer: true,
|
||||
|
||||
@@ -86,7 +87,7 @@ export const TeamCreateTool: Tool<InputSchema, Output> = buildTool({
|
||||
},
|
||||
|
||||
isEnabled() {
|
||||
return isAgentSwarmsEnabled()
|
||||
return true
|
||||
},
|
||||
|
||||
toAutoClassifierInput(input) {
|
||||
@@ -126,6 +127,12 @@ export const TeamCreateTool: Tool<InputSchema, Output> = buildTool({
|
||||
},
|
||||
|
||||
async call(input, context) {
|
||||
if (!isAgentSwarmsEnabled()) {
|
||||
throw new Error(
|
||||
'Agent Teams 功能未启用。请确保未设置 CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS_DISABLED 环境变量。',
|
||||
)
|
||||
}
|
||||
|
||||
const { setAppState, getAppState } = context
|
||||
const { team_name, description: _description, agent_type } = input
|
||||
|
||||
|
||||
@@ -50,7 +50,8 @@ export type Input = z.infer<InputSchema>
|
||||
|
||||
export const TeamDeleteTool: Tool<InputSchema, Output> = buildTool({
|
||||
name: TEAM_DELETE_TOOL_NAME,
|
||||
searchHint: 'disband a swarm team and clean up',
|
||||
searchHint:
|
||||
'disband delete swarm team cleanup, remove team, end team collaboration, cleanup team resources',
|
||||
maxResultSizeChars: 100_000,
|
||||
shouldDefer: true,
|
||||
|
||||
@@ -63,7 +64,7 @@ export const TeamDeleteTool: Tool<InputSchema, Output> = buildTool({
|
||||
},
|
||||
|
||||
isEnabled() {
|
||||
return isAgentSwarmsEnabled()
|
||||
return true
|
||||
},
|
||||
|
||||
async description() {
|
||||
@@ -88,6 +89,12 @@ export const TeamDeleteTool: Tool<InputSchema, Output> = buildTool({
|
||||
},
|
||||
|
||||
async call(input, context) {
|
||||
if (!isAgentSwarmsEnabled()) {
|
||||
throw new Error(
|
||||
'Agent Teams 功能未启用。请确保未设置 CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS_DISABLED 环境变量。',
|
||||
)
|
||||
}
|
||||
|
||||
const { setAppState, getAppState } = context
|
||||
const appState = getAppState()
|
||||
const teamName = appState.teamContext?.teamName
|
||||
|
||||
@@ -6,7 +6,7 @@ export { TOOL_SEARCH_TOOL_NAME } from './constants.js'
|
||||
|
||||
import { TOOL_SEARCH_TOOL_NAME } from './constants.js'
|
||||
|
||||
const PROMPT_HEAD = `Search for deferred tools by name or keyword. LOW PRIORITY — only use this tool when no core tool can accomplish the task. Core tools (Read, Edit, Write, Bash, Glob, Grep, Agent, WebFetch, WebSearch, Skill) are always available and should be used directly. This tool is only for discovering additional capabilities like MCP tools, cron scheduling, worktree management, etc.
|
||||
const PROMPT_HEAD = `Search for deferred tools by name or keyword. LOW PRIORITY — only use this tool when no core tool can accomplish the task. Core tools (Read, Edit, Write, Bash, Glob, Grep, Agent, WebFetch, WebSearch, Skill) are always available and should be used directly. This tool is for discovering additional capabilities like MCP tools, cron scheduling, worktree management, agent teams (TeamCreate, TeamDelete, SendMessage), etc.
|
||||
|
||||
`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user