936
// Handle server-initiated requests (e.g. consumed queued messages).
937
if (providedSession.onDidStartServerRequest) {
938
>
disposables.add(providedSession.onDidStartServerRequest(({ prompt, variableData, timestamp, isSystemInitiated, systemInitiatedLabel, isTerminalRequest }) => {
chatServiceImpl.ts
939
>
// Complete any in-flight request
940
>
if (lastRequest?.response && !lastRequest.response.isComplete) {
941
>
completeLastResponse();
942
>
}
943
>
944
>
// Create a new request in the model
945
>
const agent = this.chatAgentService.getAgent(chatSessionType);
946
>
const parsedRequest = parseAgentHostHistoryPrompt(prompt, agent);
947
>
lastRequest = model.addRequest(parsedRequest,
948
>
variableData ?? { variables: [] },
949
>
0, // attempt
950
>
undefined, // modeInfo
951
>
agent,
952
>
undefined, // slashCommand
953
>
undefined, // confirmation
954
>
undefined, // locationData
955
>
undefined, // attachments
956
>
undefined, // isCompleteAddedRequest
957
>
undefined, // modelId
958
>
undefined, // userSelectedTools
959
>
undefined, // id
960
>
isSystemInitiated,
961
>
systemInitiatedLabel,
962
>
undefined, // terminalExecutionId
963
>
isTerminalRequest,
964
>
timestamp,
965
>
);
966
>
967
>
// Reset progress tracking for the new turn
968
>
lastProgressLength = 0;
969
>
970
>
// Ensure cancellation tracking is active
971
>
ensureCancellationTracking();
972
>
}));
973
>
}
974
975
// Mid-turn steering for streamed sessions: dispatch a queued Steering message immediately