1728
throw new Error(`Cannot handle request`);
1729
}
1731
if ((token.isCancellationRequested && !rawResult)) {
1732
return;
1734
// Silent slash command completed successfully — allow queued
1735
// requests to proceed.
1736
shouldProcessPending = !token.isCancellationRequested;
1737
return;
1739
>
if (!rawResult) {
1740
this.trace('sendRequest', `Provider returned no response for session ${model.sessionResource}`);
1741
rawResult = { errorDetails: { message: localize('emptyResponse', "Provider returned null response") } };
1742
}
1744
>
const result = rawResult.errorDetails?.responseIsFiltered ? 'filtered' :
1745
>
rawResult.errorDetails && gotProgress ? 'errorWithOutput' :
1746
>
rawResult.errorDetails ? 'error' :
1747
>
'success';
1748
>
1749
>
requestTelemetry.complete({
1750
>
timeToFirstProgress: rawResult.timings?.firstProgress,
1751
>
totalTime: rawResult.timings?.totalElapsed,
1752
>
result,
1753
>
requestType,
1754
>
detectedAgent,
1755
>
request,
1756
>
});
1757
>
1758
>
model.setResponse(request, rawResult);
1759
>
completeResponseCreated();
1760
>
this.trace('sendRequest', `Provider returned response for session ${model.sessionResource}`);
1761
>
1762
>
if (rawResult.errorDetails?.isRateLimited) {
1763
this.chatEntitlementService.markAnonymousRateLimited();
1764
}
1766
>
shouldProcessPending = !rawResult.errorDetails
1767
>
&& !token.isCancellationRequested
1768
&& !request.response?.response.value.some(v => v.kind === 'confirmation' && !v.isUsed);
1770
>
1771
>
if (agentOrCommandFollowups) {
1772
>
const completedRequest = request;
1773
>
agentOrCommandFollowups.then(followups => {
1774
>
model.setFollowups(completedRequest, followups);
1775
>
const commandForTelemetry = agentSlashCommandPart ? agentSlashCommandPart.command.name : commandPart?.slashCommand.command;
1776
>
this._chatServiceTelemetry.retrievedFollowups(agentPart?.agent.id ?? '', commandForTelemetry, followups?.length ?? 0);
1777
>
});
1778
>
}
1779
>
}
1780
} catch (err) {
1781
this.logService.error(`Error while handling chat request: ${toErrorMessage(err, true)}`);