MCPcopy
hub / github.com/codeaashu/claude-code / call

Function call

src/tools/AgentTool/AgentTool.tsx:239–1263  ·  view source on GitHub ↗
({
    prompt,
    subagent_type,
    description,
    model: modelParam,
    run_in_background,
    name,
    team_name,
    mode: spawnMode,
    isolation,
    cwd
  }: AgentToolInput, toolUseContext, canUseTool, assistantMessage, onProgress?)

Source from the content-addressed store, hash-verified

237 return outputSchema();
238 },
239 async call({
240 prompt,
241 subagent_type,
242 description,
243 model: modelParam,
244 run_in_background,
245 name,
246 team_name,
247 mode: spawnMode,
248 isolation,
249 cwd
250 }: AgentToolInput, toolUseContext, canUseTool, assistantMessage, onProgress?) {
251 const startTime = Date.now();
252 const model = isCoordinatorMode() ? undefined : modelParam;
253
254 // Get app state for permission mode and agent filtering
255 const appState = toolUseContext.getAppState();
256 const permissionMode = appState.toolPermissionContext.mode;
257 // In-process teammates get a no-op setAppState; setAppStateForTasks
258 // reaches the root store so task registration/progress/kill stay visible.
259 const rootSetAppState = toolUseContext.setAppStateForTasks ?? toolUseContext.setAppState;
260
261 // Check if user is trying to use agent teams without access
262 if (team_name && !isAgentSwarmsEnabled()) {
263 throw new Error('Agent Teams is not yet available on your plan.');
264 }
265
266 // Teammates (in-process or tmux) passing `name` would trigger spawnTeammate()
267 // below, but TeamFile.members is a flat array with one leadAgentId — nested
268 // teammates land in the roster with no provenance and confuse the lead.
269 const teamName = resolveTeamName({
270 team_name
271 }, appState);
272 if (isTeammate() && teamName && name) {
273 throw new Error('Teammates cannot spawn other teammates — the team roster is flat. To spawn a subagent instead, omit the `name` parameter.');
274 }
275 // In-process teammates cannot spawn background agents (their lifecycle is
276 // tied to the leader's process). Tmux teammates are separate processes and
277 // can manage their own background agents.
278 if (isInProcessTeammate() && teamName && run_in_background === true) {
279 throw new Error('In-process teammates cannot spawn background agents. Use run_in_background=false for synchronous subagents.');
280 }
281
282 // Check if this is a multi-agent spawn request
283 // Spawn is triggered when team_name is set (from param or context) and name is provided
284 if (teamName && name) {
285 // Set agent definition color for grouped UI display before spawning
286 const agentDef = subagent_type ? toolUseContext.options.agentDefinitions.activeAgents.find(a => a.agentType === subagent_type) : undefined;
287 if (agentDef?.color) {
288 setAgentColor(subagent_type!, agentDef.color);
289 }
290 const result = await spawnTeammate({
291 name,
292 prompt,
293 description,
294 team_name: teamName,
295 use_splitpane: true,
296 plan_mode_required: spawnMode === 'plan',

Callers

nothing calls this directly

Calls 15

isCoordinatorModeFunction · 0.85
isAgentSwarmsEnabledFunction · 0.85
resolveTeamNameFunction · 0.85
isTeammateFunction · 0.85
isInProcessTeammateFunction · 0.85
setAgentColorFunction · 0.85
spawnTeammateFunction · 0.85
isForkSubagentEnabledFunction · 0.85
isInForkChildFunction · 0.85
filterDeniedAgentsFunction · 0.85
getDenyRuleForAgentFunction · 0.85
hasRequiredMcpServersFunction · 0.85

Tested by

no test coverage detected