agentgui 1.0.446 → 1.0.447

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/database.js CHANGED
@@ -341,7 +341,8 @@ try {
341
341
  workingDirectory: 'TEXT',
342
342
  claudeSessionId: 'TEXT',
343
343
  isStreaming: 'INTEGER DEFAULT 0',
344
- model: 'TEXT'
344
+ model: 'TEXT',
345
+ subAgent: 'TEXT'
345
346
  };
346
347
 
347
348
  let addedColumns = false;
@@ -527,13 +528,13 @@ function generateId(prefix) {
527
528
 
528
529
  export const queries = {
529
530
  _db: db,
530
- createConversation(agentType, title = null, workingDirectory = null, model = null) {
531
+ createConversation(agentType, title = null, workingDirectory = null, model = null, subAgent = null) {
531
532
  const id = generateId('conv');
532
533
  const now = Date.now();
533
534
  const stmt = prep(
534
- `INSERT INTO conversations (id, agentId, agentType, title, created_at, updated_at, status, workingDirectory, model) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`
535
+ `INSERT INTO conversations (id, agentId, agentType, title, created_at, updated_at, status, workingDirectory, model, subAgent) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
535
536
  );
536
- stmt.run(id, agentType, agentType, title, now, now, 'active', workingDirectory, model);
537
+ stmt.run(id, agentType, agentType, title, now, now, 'active', workingDirectory, model, subAgent);
537
538
 
538
539
  return {
539
540
  id,
@@ -541,6 +542,7 @@ export const queries = {
541
542
  title,
542
543
  workingDirectory,
543
544
  model,
545
+ subAgent,
544
546
  created_at: now,
545
547
  updated_at: now,
546
548
  status: 'active'
@@ -559,7 +561,7 @@ export const queries = {
559
561
 
560
562
  getConversationsList() {
561
563
  const stmt = prep(
562
- 'SELECT id, agentId, title, agentType, created_at, updated_at, messageCount, workingDirectory, isStreaming, model FROM conversations WHERE status != ? ORDER BY updated_at DESC'
564
+ 'SELECT id, agentId, title, agentType, created_at, updated_at, messageCount, workingDirectory, isStreaming, model, subAgent FROM conversations WHERE status != ? ORDER BY updated_at DESC'
563
565
  );
564
566
  return stmt.all('deleted');
565
567
  },
@@ -579,11 +581,12 @@ export const queries = {
579
581
  const agentId = data.agentId !== undefined ? data.agentId : conv.agentId;
580
582
  const agentType = data.agentType !== undefined ? data.agentType : conv.agentType;
581
583
  const model = data.model !== undefined ? data.model : conv.model;
584
+ const subAgent = data.subAgent !== undefined ? data.subAgent : conv.subAgent;
582
585
 
583
586
  const stmt = prep(
584
- `UPDATE conversations SET title = ?, status = ?, agentId = ?, agentType = ?, model = ?, updated_at = ? WHERE id = ?`
587
+ `UPDATE conversations SET title = ?, status = ?, agentId = ?, agentType = ?, model = ?, subAgent = ?, updated_at = ? WHERE id = ?`
585
588
  );
586
- stmt.run(title, status, agentId, agentType, model, now, id);
589
+ stmt.run(title, status, agentId, agentType, model, subAgent, now, id);
587
590
 
588
591
  return {
589
592
  ...conv,
@@ -592,6 +595,7 @@ export const queries = {
592
595
  agentId,
593
596
  agentType,
594
597
  model,
598
+ subAgent,
595
599
  updated_at: now
596
600
  };
597
601
  },
@@ -619,13 +623,13 @@ export const queries = {
619
623
  },
620
624
 
621
625
  getStreamingConversations() {
622
- const stmt = prep('SELECT id, title, claudeSessionId, agentId, agentType, model FROM conversations WHERE isStreaming = 1');
626
+ const stmt = prep('SELECT id, title, claudeSessionId, agentId, agentType, model, subAgent FROM conversations WHERE isStreaming = 1');
623
627
  return stmt.all();
624
628
  },
625
629
 
626
630
  getResumableConversations() {
627
631
  const stmt = prep(
628
- "SELECT id, title, claudeSessionId, agentId, agentType, workingDirectory, model FROM conversations WHERE isStreaming = 1 AND claudeSessionId IS NOT NULL AND claudeSessionId != ''"
632
+ "SELECT id, title, claudeSessionId, agentId, agentType, workingDirectory, model, subAgent FROM conversations WHERE isStreaming = 1 AND claudeSessionId IS NOT NULL AND claudeSessionId != ''"
629
633
  );
630
634
  return stmt.all();
631
635
  },
@@ -359,6 +359,7 @@ class AgentRunner {
359
359
  mcpServers: []
360
360
  };
361
361
  if (config.model) sessionParams.model = config.model;
362
+ if (config.subAgent) sessionParams.agent = config.subAgent;
362
363
  const sessionRequest = {
363
364
  jsonrpc: '2.0',
364
365
  id: ++requestId,
@@ -15,8 +15,8 @@ export function register(router, deps) {
15
15
 
16
16
  router.handle('conv.new', (p) => {
17
17
  const wd = p.workingDirectory ? path.resolve(p.workingDirectory) : null;
18
- const conv = queries.createConversation(p.agentId, p.title, wd, p.model || null);
19
- queries.createEvent('conversation.created', { agentId: p.agentId, workingDirectory: conv.workingDirectory, model: conv.model }, conv.id);
18
+ const conv = queries.createConversation(p.agentId, p.title, wd, p.model || null, p.subAgent || null);
19
+ queries.createEvent('conversation.created', { agentId: p.agentId, workingDirectory: conv.workingDirectory, model: conv.model, subAgent: conv.subAgent }, conv.id);
20
20
  broadcastSync({ type: 'conversation_created', conversation: conv });
21
21
  return { conversation: conv };
22
22
  });
@@ -87,7 +87,7 @@ export function register(router, deps) {
87
87
  if (!entry) {
88
88
  const agentId = conv.agentId || 'claude-code';
89
89
  const session = queries.createSession(p.id, agentId, 'pending');
90
- processMessageWithStreaming(p.id, message.id, session.id, message.content, agentId, conv.model || null);
90
+ processMessageWithStreaming(p.id, message.id, session.id, message.content, agentId, conv.model || null, conv.subAgent || null);
91
91
  }
92
92
  return { ok: true, injected: true, conversationId: p.id, messageId: message.id };
93
93
  });
@@ -96,19 +96,19 @@ export function register(router, deps) {
96
96
  return queries.getPaginatedMessages(p.id, Math.min(p.limit || 50, 100), Math.max(p.offset || 0, 0));
97
97
  });
98
98
 
99
- function startExecution(convId, message, agentId, model, content) {
99
+ function startExecution(convId, message, agentId, model, content, subAgent) {
100
100
  const session = queries.createSession(convId);
101
101
  queries.createEvent('session.created', { messageId: message.id, sessionId: session.id }, convId, session.id);
102
102
  activeExecutions.set(convId, { pid: null, startTime: Date.now(), sessionId: session.id, lastActivity: Date.now() });
103
103
  queries.setIsStreaming(convId, true);
104
104
  broadcastSync({ type: 'streaming_start', sessionId: session.id, conversationId: convId, messageId: message.id, agentId, timestamp: Date.now() });
105
- processMessageWithStreaming(convId, message.id, session.id, content, agentId, model).catch(() => {});
105
+ processMessageWithStreaming(convId, message.id, session.id, content, agentId, model, subAgent).catch(() => {});
106
106
  return session;
107
107
  }
108
108
 
109
- function enqueue(convId, content, agentId, model, messageId) {
109
+ function enqueue(convId, content, agentId, model, messageId, subAgent) {
110
110
  if (!messageQueues.has(convId)) messageQueues.set(convId, []);
111
- messageQueues.get(convId).push({ content, agentId, model, messageId });
111
+ messageQueues.get(convId).push({ content, agentId, model, messageId, subAgent });
112
112
  const queueLength = messageQueues.get(convId).length;
113
113
  broadcastSync({ type: 'queue_status', conversationId: convId, queueLength, messageId, timestamp: Date.now() });
114
114
  return queueLength;
@@ -119,15 +119,16 @@ export function register(router, deps) {
119
119
  if (!conv) notFound('Conversation not found');
120
120
  const agentId = p.agentId || conv.agentType || conv.agentId || 'claude-code';
121
121
  const model = p.model || conv.model || null;
122
+ const subAgent = p.subAgent || conv.subAgent || null;
122
123
  const idempotencyKey = p.idempotencyKey || null;
123
124
  const message = queries.createMessage(p.id, 'user', p.content, idempotencyKey);
124
125
  queries.createEvent('message.created', { role: 'user', messageId: message.id }, p.id);
125
126
  broadcastSync({ type: 'message_created', conversationId: p.id, message, timestamp: Date.now() });
126
127
  if (activeExecutions.has(p.id)) {
127
- const qp = enqueue(p.id, p.content, agentId, model, message.id);
128
+ const qp = enqueue(p.id, p.content, agentId, model, message.id, subAgent);
128
129
  return { message, queued: true, queuePosition: qp, idempotencyKey };
129
130
  }
130
- const session = startExecution(p.id, message, agentId, model, p.content);
131
+ const session = startExecution(p.id, message, agentId, model, p.content, subAgent);
131
132
  return { message, session, idempotencyKey };
132
133
  });
133
134
 
@@ -143,14 +144,15 @@ export function register(router, deps) {
143
144
  const prompt = p.content || p.message || '';
144
145
  const agentId = p.agentId || conv.agentType || conv.agentId || 'claude-code';
145
146
  const model = p.model || conv.model || null;
147
+ const subAgent = p.subAgent || conv.subAgent || null;
146
148
  const userMessage = queries.createMessage(p.id, 'user', prompt);
147
149
  queries.createEvent('message.created', { role: 'user', messageId: userMessage.id }, p.id);
148
150
  broadcastSync({ type: 'message_created', conversationId: p.id, message: userMessage, timestamp: Date.now() });
149
151
  if (activeExecutions.has(p.id)) {
150
- const qp = enqueue(p.id, prompt, agentId, model, userMessage.id);
152
+ const qp = enqueue(p.id, prompt, agentId, model, userMessage.id, subAgent);
151
153
  return { message: userMessage, queued: true, queuePosition: qp };
152
154
  }
153
- const session = startExecution(p.id, userMessage, agentId, model, prompt);
155
+ const session = startExecution(p.id, userMessage, agentId, model, prompt, subAgent);
154
156
  return { message: userMessage, session, streamId: session.id };
155
157
  });
156
158
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.446",
3
+ "version": "1.0.447",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "server.js",
package/server.js CHANGED
@@ -1045,6 +1045,7 @@ const server = http.createServer(async (req, res) => {
1045
1045
  const body = await parseBody(req);
1046
1046
  const agentId = body.agentId || conv.agentType || conv.agentId || 'claude-code';
1047
1047
  const model = body.model || conv.model || null;
1048
+ const subAgent = body.subAgent || conv.subAgent || null;
1048
1049
  const idempotencyKey = body.idempotencyKey || null;
1049
1050
  const message = queries.createMessage(conversationId, 'user', body.content, idempotencyKey);
1050
1051
  queries.createEvent('message.created', { role: 'user', messageId: message.id }, conversationId);
@@ -1052,7 +1053,7 @@ const server = http.createServer(async (req, res) => {
1052
1053
 
1053
1054
  if (activeExecutions.has(conversationId)) {
1054
1055
  if (!messageQueues.has(conversationId)) messageQueues.set(conversationId, []);
1055
- messageQueues.get(conversationId).push({ content: body.content, agentId, model, messageId: message.id });
1056
+ messageQueues.get(conversationId).push({ content: body.content, agentId, model, messageId: message.id, subAgent });
1056
1057
  const queueLength = messageQueues.get(conversationId).length;
1057
1058
  broadcastSync({ type: 'queue_status', conversationId, queueLength, messageId: message.id, timestamp: Date.now() });
1058
1059
  sendJSON(req, res, 200, { message, queued: true, queuePosition: queueLength, idempotencyKey });
@@ -1076,7 +1077,7 @@ const server = http.createServer(async (req, res) => {
1076
1077
 
1077
1078
  sendJSON(req, res, 201, { message, session, idempotencyKey });
1078
1079
 
1079
- processMessageWithStreaming(conversationId, message.id, session.id, body.content, agentId, model)
1080
+ processMessageWithStreaming(conversationId, message.id, session.id, body.content, agentId, model, subAgent)
1080
1081
  .catch(err => {
1081
1082
  console.error(`[messages] Uncaught error for conv ${conversationId}:`, err.message);
1082
1083
  debugLog(`[messages] Uncaught error: ${err.message}`);
@@ -1095,6 +1096,7 @@ const server = http.createServer(async (req, res) => {
1095
1096
  const prompt = body.content || body.message || '';
1096
1097
  const agentId = body.agentId || conv.agentType || conv.agentId || 'claude-code';
1097
1098
  const model = body.model || conv.model || null;
1099
+ const subAgent = body.subAgent || conv.subAgent || null;
1098
1100
 
1099
1101
  const userMessage = queries.createMessage(conversationId, 'user', prompt);
1100
1102
  queries.createEvent('message.created', { role: 'user', messageId: userMessage.id }, conversationId);
@@ -1104,7 +1106,7 @@ const server = http.createServer(async (req, res) => {
1104
1106
  if (activeExecutions.has(conversationId)) {
1105
1107
  debugLog(`[stream] Conversation ${conversationId} is busy, queuing message`);
1106
1108
  if (!messageQueues.has(conversationId)) messageQueues.set(conversationId, []);
1107
- messageQueues.get(conversationId).push({ content: prompt, agentId, model, messageId: userMessage.id });
1109
+ messageQueues.get(conversationId).push({ content: prompt, agentId, model, messageId: userMessage.id, subAgent });
1108
1110
 
1109
1111
  const queueLength = messageQueues.get(conversationId).length;
1110
1112
  broadcastSync({ type: 'queue_status', conversationId, queueLength, messageId: userMessage.id, timestamp: Date.now() });
@@ -1130,7 +1132,7 @@ const server = http.createServer(async (req, res) => {
1130
1132
 
1131
1133
  sendJSON(req, res, 200, { message: userMessage, session, streamId: session.id });
1132
1134
 
1133
- processMessageWithStreaming(conversationId, userMessage.id, session.id, prompt, agentId, model)
1135
+ processMessageWithStreaming(conversationId, userMessage.id, session.id, prompt, agentId, model, subAgent)
1134
1136
  .catch(err => debugLog(`[stream] Uncaught error: ${err.message}`));
1135
1137
  return;
1136
1138
  }
@@ -3148,7 +3150,7 @@ function createChunkBatcher() {
3148
3150
  return { add, drain };
3149
3151
  }
3150
3152
 
3151
- async function processMessageWithStreaming(conversationId, messageId, sessionId, content, agentId, model) {
3153
+ async function processMessageWithStreaming(conversationId, messageId, sessionId, content, agentId, model, subAgent) {
3152
3154
  const startTime = Date.now();
3153
3155
  touchACP(agentId);
3154
3156
 
@@ -3309,7 +3311,7 @@ async function processMessageWithStreaming(conversationId, messageId, sessionId,
3309
3311
  conversationId,
3310
3312
  timestamp: Date.now()
3311
3313
  });
3312
- scheduleRetry(conversationId, messageId, content, agentId, model);
3314
+ scheduleRetry(conversationId, messageId, content, agentId, model, subAgent);
3313
3315
  }, retryAfterSec * 1000);
3314
3316
 
3315
3317
  return; // Stop processing events
@@ -3431,7 +3433,7 @@ async function processMessageWithStreaming(conversationId, messageId, sessionId,
3431
3433
  conversationId,
3432
3434
  timestamp: Date.now()
3433
3435
  });
3434
- scheduleRetry(conversationId, messageId, content, agentId, model);
3436
+ scheduleRetry(conversationId, messageId, content, agentId, model, subAgent);
3435
3437
  }, retryAfterSec * 1000);
3436
3438
 
3437
3439
  return;
@@ -3487,6 +3489,7 @@ async function processMessageWithStreaming(conversationId, messageId, sessionId,
3487
3489
  };
3488
3490
 
3489
3491
  const resolvedModel = model || conv?.model || null;
3492
+ const resolvedSubAgent = subAgent || conv?.subAgent || null;
3490
3493
  const config = {
3491
3494
  verbose: true,
3492
3495
  outputFormat: 'stream-json',
@@ -3495,6 +3498,7 @@ async function processMessageWithStreaming(conversationId, messageId, sessionId,
3495
3498
  resumeSessionId,
3496
3499
  systemPrompt: SYSTEM_PROMPT,
3497
3500
  model: resolvedModel || undefined,
3501
+ subAgent: resolvedSubAgent || undefined,
3498
3502
  onEvent,
3499
3503
  onPid: (pid) => {
3500
3504
  const entry = activeExecutions.get(conversationId);
@@ -3611,7 +3615,7 @@ async function processMessageWithStreaming(conversationId, messageId, sessionId,
3611
3615
  conversationId,
3612
3616
  timestamp: Date.now()
3613
3617
  });
3614
- scheduleRetry(conversationId, messageId, content, agentId, model);
3618
+ scheduleRetry(conversationId, messageId, content, agentId, model, subAgent);
3615
3619
  }, cooldownMs);
3616
3620
  return;
3617
3621
  }
@@ -3645,7 +3649,7 @@ async function processMessageWithStreaming(conversationId, messageId, sessionId,
3645
3649
  }
3646
3650
  }
3647
3651
 
3648
- function scheduleRetry(conversationId, messageId, content, agentId, model) {
3652
+ function scheduleRetry(conversationId, messageId, content, agentId, model, subAgent) {
3649
3653
  debugLog(`[rate-limit] scheduleRetry called for conv ${conversationId}, messageId=${messageId}`);
3650
3654
 
3651
3655
  if (!content) {
@@ -3672,7 +3676,7 @@ function scheduleRetry(conversationId, messageId, content, agentId, model) {
3672
3676
  activeExecutions.set(conversationId, { pid: null, startTime, sessionId: newSession.id, lastActivity: startTime });
3673
3677
 
3674
3678
  debugLog(`[rate-limit] Calling processMessageWithStreaming for retry`);
3675
- processMessageWithStreaming(conversationId, messageId, newSession.id, content, agentId, model)
3679
+ processMessageWithStreaming(conversationId, messageId, newSession.id, content, agentId, model, subAgent)
3676
3680
  .catch(err => {
3677
3681
  debugLog(`[rate-limit] Retry failed: ${err.message}`);
3678
3682
  console.error(`[rate-limit] Retry error for conv ${conversationId}:`, err);
@@ -3710,7 +3714,7 @@ function drainMessageQueue(conversationId) {
3710
3714
  const startTime = Date.now();
3711
3715
  activeExecutions.set(conversationId, { pid: null, startTime, sessionId: session.id, lastActivity: startTime });
3712
3716
 
3713
- processMessageWithStreaming(conversationId, next.messageId, session.id, next.content, next.agentId, next.model)
3717
+ processMessageWithStreaming(conversationId, next.messageId, session.id, next.content, next.agentId, next.model, next.subAgent)
3714
3718
  .catch(err => debugLog(`[queue] Error processing queued message: ${err.message}`));
3715
3719
  }
3716
3720
 
@@ -4074,7 +4078,7 @@ async function resumeInterruptedStreams() {
4074
4078
  const messageId = lastMsg?.id || null;
4075
4079
  console.log(`[RESUME] Resuming conv ${conv.id} (claude session: ${conv.claudeSessionId})`);
4076
4080
 
4077
- processMessageWithStreaming(conv.id, messageId, session.id, promptText, conv.agentType, conv.model)
4081
+ processMessageWithStreaming(conv.id, messageId, session.id, promptText, conv.agentType, conv.model, conv.subAgent)
4078
4082
  .catch(err => debugLog(`[RESUME] Error resuming conv ${conv.id}: ${err.message}`));
4079
4083
 
4080
4084
  if (i < toResume.length - 1) {
@@ -1260,6 +1260,7 @@ class AgentGUIClient {
1260
1260
  const conv = this.state.currentConversation;
1261
1261
  const isNewConversation = conv && !conv.messageCount && !this.state.streamingConversations.has(conv.id);
1262
1262
  const agentId = (isNewConversation ? this.getCurrentAgent() : null) || conv?.agentType || this.getCurrentAgent();
1263
+ const subAgent = this.getEffectiveSubAgent() || conv?.subAgent || null;
1263
1264
  const model = this.ui.modelSelector?.value || null;
1264
1265
 
1265
1266
  if (!prompt.trim()) {
@@ -1280,11 +1281,12 @@ class AgentGUIClient {
1280
1281
  try {
1281
1282
  if (conv?.id) {
1282
1283
  this.lockAgentAndModel(agentId, model);
1283
- await this.streamToConversation(conv.id, savedPrompt, agentId, model);
1284
+ await this.streamToConversation(conv.id, savedPrompt, agentId, model, subAgent);
1284
1285
  this._confirmOptimisticMessage(pendingId);
1285
1286
  } else {
1286
1287
  const body = { agentId, title: savedPrompt.substring(0, 50) };
1287
1288
  if (model) body.model = model;
1289
+ if (subAgent) body.subAgent = subAgent;
1288
1290
  const { conversation } = await window.wsClient.rpc('conv.new', body);
1289
1291
  this.state.currentConversation = conversation;
1290
1292
  this.lockAgentAndModel(agentId, model);
@@ -1294,7 +1296,7 @@ class AgentGUIClient {
1294
1296
  window.conversationManager.select(conversation.id);
1295
1297
  }
1296
1298
 
1297
- await this.streamToConversation(conversation.id, savedPrompt, agentId, model);
1299
+ await this.streamToConversation(conversation.id, savedPrompt, agentId, model, subAgent);
1298
1300
  this._confirmOptimisticMessage(pendingId);
1299
1301
  }
1300
1302
  } catch (error) {
@@ -1535,7 +1537,7 @@ class AgentGUIClient {
1535
1537
  `;
1536
1538
  }
1537
1539
 
1538
- async streamToConversation(conversationId, prompt, agentId, model) {
1540
+ async streamToConversation(conversationId, prompt, agentId, model, subAgent) {
1539
1541
  try {
1540
1542
  if (this.wsManager.isConnected) {
1541
1543
  this.wsManager.sendMessage({ type: 'subscribe', conversationId });
@@ -1543,6 +1545,7 @@ class AgentGUIClient {
1543
1545
 
1544
1546
  const streamBody = { id: conversationId, content: prompt, agentId };
1545
1547
  if (model) streamBody.model = model;
1548
+ if (subAgent) streamBody.subAgent = subAgent;
1546
1549
  let result;
1547
1550
  try {
1548
1551
  result = await window.wsClient.rpc('msg.stream', streamBody);
@@ -1552,6 +1555,7 @@ class AgentGUIClient {
1552
1555
  const conv = this.state.currentConversation;
1553
1556
  const createBody = { agentId, title: conv?.title || prompt.substring(0, 50), workingDirectory: conv?.workingDirectory || null };
1554
1557
  if (model) createBody.model = model;
1558
+ if (subAgent) createBody.subAgent = subAgent;
1555
1559
  const { conversation: newConv } = await window.wsClient.rpc('conv.new', createBody);
1556
1560
  this.state.currentConversation = newConv;
1557
1561
  if (window.conversationManager) {
@@ -1559,7 +1563,7 @@ class AgentGUIClient {
1559
1563
  window.conversationManager.select(newConv.id);
1560
1564
  }
1561
1565
  this.updateUrlForConversation(newConv.id);
1562
- return this.streamToConversation(newConv.id, prompt, agentId, model);
1566
+ return this.streamToConversation(newConv.id, prompt, agentId, model, subAgent);
1563
1567
  }
1564
1568
  throw e;
1565
1569
  }
@@ -1971,6 +1975,7 @@ class AgentGUIClient {
1971
1975
  applyAgentAndModelSelection(conversation, hasActivity) {
1972
1976
  const agentId = conversation.agentId || conversation.agentType || null;
1973
1977
  const model = conversation.model || null;
1978
+ const subAgent = conversation.subAgent || null;
1974
1979
 
1975
1980
  if (hasActivity) {
1976
1981
  this._setCliSelectorToAgent(agentId);
@@ -1980,6 +1985,11 @@ class AgentGUIClient {
1980
1985
  this._setCliSelectorToAgent(agentId);
1981
1986
 
1982
1987
  const effectiveAgentId = agentId || this.getEffectiveAgentId();
1988
+ this.loadSubAgentsForCli(effectiveAgentId).then(() => {
1989
+ if (subAgent && this.ui.agentSelector) {
1990
+ this.ui.agentSelector.value = subAgent;
1991
+ }
1992
+ });
1983
1993
  this.loadModelsForAgent(effectiveAgentId).then(() => {
1984
1994
  if (model && this.ui.modelSelector) {
1985
1995
  this.ui.modelSelector.value = model;
@@ -2561,10 +2571,14 @@ class AgentGUIClient {
2561
2571
  * Get current selected agent
2562
2572
  */
2563
2573
  getEffectiveAgentId() {
2574
+ return this.ui.cliSelector?.value || null;
2575
+ }
2576
+
2577
+ getEffectiveSubAgent() {
2564
2578
  if (this.ui.agentSelector?.value && this.ui.agentSelector.style.display !== 'none') {
2565
2579
  return this.ui.agentSelector.value;
2566
2580
  }
2567
- return this.ui.cliSelector?.value || null;
2581
+ return null;
2568
2582
  }
2569
2583
 
2570
2584
  getCurrentAgent() {
@@ -2575,8 +2589,9 @@ class AgentGUIClient {
2575
2589
  const convId = this.state.currentConversation;
2576
2590
  if (!convId || this._agentLocked) return;
2577
2591
  const agentId = this.getEffectiveAgentId();
2592
+ const subAgent = this.getEffectiveSubAgent();
2578
2593
  const model = this.getCurrentModel();
2579
- window.wsClient.rpc('conv.upd', { id: convId, agentType: agentId, model: model || undefined }).catch(() => {});
2594
+ window.wsClient.rpc('conv.upd', { id: convId, agentType: agentId, subAgent: subAgent || undefined, model: model || undefined }).catch(() => {});
2580
2595
  }
2581
2596
 
2582
2597
  /**