@@ -14,6 +14,7 @@ import kotlinx.serialization.json.Json
1414 * Agents command implementation for listing and invoking AI agents.
1515 *
1616 * Example:
17+ * List all agents:
1718 * ```devin
1819 * /agents
1920 * ```
@@ -258,33 +259,31 @@ class AgentsInsCommand(
258259return " ${DEVINS_ERROR } Error invoking A2A agent '$agentName ':${e.message} "
259260 }
260261 }
261- // If agent not found in A2A, continue to try DevIns agents
262262 }
263263
264- // Try to find and invoke DevIns agent
265264val devInsAgents= DevInsAgentToolCollector .all(project)
266265val devInsAgent= devInsAgents.find { it.name== agentName }
267266
268- if (devInsAgent!= null ) {
269- return try {
270- val collectors= com.intellij.openapi.extensions.ExtensionPointName
271- .create<DevInsAgentToolCollector >(" cc.unitmesh.devInsAgentTool" )
272- .extensionList
267+ if (devInsAgent== null ) {
268+ // Agent not found
269+ return " ${DEVINS_ERROR } Agent '$agentName ' not found. Use /agents to list all available agents."
270+ }
273271
274- for (collectorin collectors) {
275- val result= collector.execute(project, agentName, input)
276- if (result!= null ) {
277- return " DevIns Agent '$agentName ' response:\n $result "
278- }
279- }
272+ return try {
273+ val collectors= com.intellij.openapi.extensions.ExtensionPointName
274+ .create<DevInsAgentToolCollector >(" cc.unitmesh.devInsAgentTool" )
275+ .extensionList
280276
281- " ${DEVINS_ERROR } Failed to execute DevIns agent '$agentName '"
282- }catch (e: Exception ) {
283- " ${DEVINS_ERROR } Error executing DevIns agent '$agentName ':${e.message} "
277+ for (collectorin collectors) {
278+ val result= collector.execute(project, agentName, input)
279+ if (result!= null ) {
280+ return " DevIns Agent '$agentName ' response:\n $result "
281+ }
284282 }
285- }
286283
287- // Agent not found
288- return " ${DEVINS_ERROR } Agent '$agentName ' not found. Use /agents to list all available agents."
284+ " ${DEVINS_ERROR } Failed to execute DevIns agent '$agentName '"
285+ }catch (e: Exception ) {
286+ " ${DEVINS_ERROR } Error executing DevIns agent '$agentName ':${e.message} "
287+ }
289288 }
290289}