@@ -20,12 +20,12 @@ import { ILogService } from '../../log/common/logService';
20
20
import { FinishedCallback , IResponseDelta , OpenAiResponsesFunctionTool } from '../../networking/common/fetch' ;
21
21
import { ICreateEndpointBodyOptions , IEndpointBody } from '../../networking/common/networking' ;
22
22
import { ChatCompletion , FinishedCompletionReason , TokenLogProb } from '../../networking/common/openai' ;
23
+ import { IExperimentationService } from '../../telemetry/common/nullExperimentationService' ;
23
24
import { ITelemetryService } from '../../telemetry/common/telemetry' ;
24
25
import { TelemetryData } from '../../telemetry/common/telemetryData' ;
25
26
import { IChatModelInformation } from '../common/endpointProvider' ;
26
27
import { getStatefulMarkerAndIndex } from '../common/statefulMarkerContainer' ;
27
28
import { rawPartAsThinkingData } from '../common/thinkingDataContainer' ;
28
- import { IExperimentationService } from '../../telemetry/common/nullExperimentationService' ;
29
29
30
30
export function createResponsesRequestBody ( accessor : ServicesAccessor , options : ICreateEndpointBodyOptions , model : string , modelInfo : IChatModelInformation ) : IEndpointBody {
31
31
const configService = accessor . get ( IConfigurationService ) ;
@@ -84,14 +84,17 @@ function rawMessagesToResponseAPI(modelId: string, messages: readonly Raw.ChatMe
84
84
case Raw . ChatRole . Assistant :
85
85
if ( message . content . length ) {
86
86
input . push ( ...extractThinkingData ( message . content ) ) ;
87
- input . push ( {
88
- role : 'assistant' ,
89
- content : message . content . map ( rawContentToResponsesOutputContent ) . filter ( isDefined ) ,
90
- // I don't think this needs to be round-tripped.
91
- id : 'msg_123' ,
92
- status : 'completed' ,
93
- type : 'message' ,
94
- } satisfies OpenAI . Responses . ResponseOutputMessage ) ;
87
+ const asstContent = message . content . map ( rawContentToResponsesOutputContent ) . filter ( isDefined ) ;
88
+ if ( asstContent . length ) {
89
+ input . push ( {
90
+ role : 'assistant' ,
91
+ content : asstContent ,
92
+ // I don't think this needs to be round-tripped.
93
+ id : 'msg_123' ,
94
+ status : 'completed' ,
95
+ type : 'message' ,
96
+ } satisfies OpenAI . Responses . ResponseOutputMessage ) ;
97
+ }
95
98
}
96
99
if ( message . toolCalls ) {
97
100
for ( const toolCall of message . toolCalls ) {
@@ -150,7 +153,9 @@ function rawContentToResponsesContent(part: Raw.ChatCompletionContentPart): Open
150
153
function rawContentToResponsesOutputContent ( part : Raw . ChatCompletionContentPart ) : OpenAI . Responses . ResponseOutputText | OpenAI . Responses . ResponseOutputRefusal | undefined {
151
154
switch ( part . type ) {
152
155
case Raw . ChatCompletionContentPartKind . Text :
153
- return { type : 'output_text' , text : part . text , annotations : [ ] } ;
156
+ if ( part . text . trim ( ) ) {
157
+ return { type : 'output_text' , text : part . text , annotations : [ ] } ;
158
+ }
154
159
}
155
160
}
156
161
0 commit comments