1445
return;
1446
}
1448
>
const msg = state.queuedMessages[0];
1449
>
const turnId = generateUuid();
1450
>
1451
>
// Per-turn streaming part tracking is owned by the agent (reset
1452
>
// inside its `send()` call), so no host-side reset is needed.
1453
>
1454
>
// Dispatch server-initiated turn start; the reducer removes the queued message atomically
1455
>
this._stateManager.dispatchServerAction(session, {
1456
>
type: ActionType.ChatTurnStarted,
1457
>
turnId,
1458
>
startedAt: new Date().toISOString(),
1459
>
message: msg.message,
1460
>
queuedMessageId: msg.id,
1461
>
});
1462
>
const turnStopWatch = StopWatch.create(false);
1463
>
1464
>
// Generic host commands (`/rename`, `!command`, …) are intercepted by
1465
>
// the local-command dispatcher (see the ChatTurnStarted handler) and
1466
>
// must not reach the agent SDK even when queued.
1467
>
const handled = this._localCommands.tryHandle({ turnChannel: session, turnId, text: msg.message.text });
1468
>
if (handled) {
1469
// A local command may suggest a provisional title (e.g. a `!command`
1470
// dequeued before any real request has titled the session).