MCPcopy Index your code
hub / github.com/codeaashu/claude-code / refreshAgentDefinitionsForModeSwitch

Function refreshAgentDefinitionsForModeSwitch

src/utils/sessionRestore.ts:251–271  ·  view source on GitHub ↗
(
  modeWasSwitched: boolean,
  currentCwd: string,
  cliAgents: AgentDefinition[],
  currentAgentDefinitions: AgentDefinitionsResult,
)

Source from the content-addressed store, hash-verified

249 * agents (from --agents flag) are merged back in.
250 */
251export async function refreshAgentDefinitionsForModeSwitch(
252 modeWasSwitched: boolean,
253 currentCwd: string,
254 cliAgents: AgentDefinition[],
255 currentAgentDefinitions: AgentDefinitionsResult,
256): Promise<AgentDefinitionsResult> {
257 if (!feature('COORDINATOR_MODE') || !modeWasSwitched) {
258 return currentAgentDefinitions
259 }
260
261 // Re-derive agent definitions after mode switch so built-in agents
262 // reflect the new coordinator/normal mode
263 getAgentDefinitionsWithOverrides.cache.clear?.()
264 const freshAgentDefs = await getAgentDefinitionsWithOverrides(currentCwd)
265 const freshAllAgents = [...freshAgentDefs.allAgents, ...cliAgents]
266 return {
267 ...freshAgentDefs,
268 allAgents: freshAllAgents,
269 activeAgents: getActiveAgentsFromList(freshAllAgents),
270 }
271}
272
273/**
274 * Result of processing a resumed/continued conversation for rendering.

Callers 1

Calls 3

featureFunction · 0.85
getActiveAgentsFromListFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected