2250
2251
if (this._isServerManagedQueue(sessionResource)) {
2252
>
// Agent host queues are drained by the server, which intentionally
chatServiceImpl.ts
2253
>
// skips pending messages on cancellation. So remove the message
2254
>
// (clearing it server-side) and re-send it as a normal turn after
2255
>
// cancelling. Remove before sending to avoid the server also
2256
>
// auto-draining it (double send); restore it on failure so a
2257
>
// rejected re-send doesn't silently drop the message.
2258
>
const message = target.request.message.text;
2259
>
const attachedContext = target.request.variableData.variables.slice();
2260
>
const sendOptions: IChatSendRequestOptions = {
2261
>
...target.sendOptions,
2262
>
queue: undefined,
2263
>
attachedContext,
2264
>
};
2265
>
this.removePendingRequest(sessionResource, requestId);
2266
>
await this.cancelCurrentRequestForSession(sessionResource, 'queueRunNext');
2267
>
let result: ChatSendResult | undefined;
2268
>
try {
2269
>
result = await this.sendRequest(sessionResource, message, sendOptions);
2270
>
} catch (err) {
2271
this.logService.error('sendPendingRequestImmediately: re-send failed', err);
2272
}
2274
this.info('sendPendingRequestImmediately', `Re-send was not accepted (${result?.kind ?? 'error'}); restoring pending message to the queue`);
2275
await this.sendRequest(sessionResource, message, { ...sendOptions, attachedContext, queue: target.kind });
2276
}
2278
>
}
2279
2280
// Local sessions: move the target to the front (keeping its kind),