( modeWasSwitched: boolean, currentCwd: string, cliAgents: AgentDefinition[], currentAgentDefinitions: AgentDefinitionsResult, )
| 249 | * agents (from --agents flag) are merged back in. |
| 250 | */ |
| 251 | export 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. |
no test coverage detected