File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1031,6 +1031,32 @@ mod tests {
10311031 ) ;
10321032 }
10331033
1034+ #[ tokio:: test]
1035+ async fn execute_streaming_errors_when_model_returns_empty_delta_stream ( ) {
1036+ // L3 回归:saw_data_event=true 但所有 delta 均无 content(模型返空),
1037+ // 与端点忽略 stream 参数统一报 "no usable content",不再静默返回空
1038+ // 成功;提示语指明 empty delta stream 以区分两种成因。
1039+ let body = "data: {\" choices\" :[{\" delta\" :{}}]}\n \n data: [DONE]\n \n " . to_string ( ) ;
1040+ let ( base_url, _request_rx) = serve_once ( "HTTP/1.1 200 OK" , body) . await ;
1041+ let ( _tmp, ctx) = workspace_with_image ( ) ;
1042+ let mut config = fake_config ( ) ;
1043+ config. base_url = Some ( base_url) ;
1044+ let tool = ImageAnalyzeTool :: new ( config) ;
1045+
1046+ let err = tool
1047+ . execute ( json ! ( { "image_path" : "img.png" } ) , & ctx)
1048+ . await
1049+ . expect_err ( "empty delta stream must error instead of returning empty success" ) ;
1050+ assert ! (
1051+ err. to_string( ) . contains( "no usable content" ) ,
1052+ "error must call out the unified 'no usable content' message; got {err}"
1053+ ) ;
1054+ assert ! (
1055+ err. to_string( ) . contains( "empty delta stream" ) ,
1056+ "error must hint at the model returning empty deltas; got {err}"
1057+ ) ;
1058+ }
1059+
10341060 #[ tokio:: test]
10351061 async fn execute_non_streaming_parses_plain_json_response ( ) {
10361062 let body =
You can’t perform that action at this time.
0 commit comments