Please share your method/approach to write long melodic licks/runs/sequences/phrases on your instrument(preferably guitar). I can write short melodic short phrases like in Blues, for example, but having trouble in writing long phrases. It either starts sounding practicing minor scale run or ancient shred machines.
Take your short blues licks and connect them into longer flowing phrases that extend beyond the box pattern. This is about the easiest and most relevant way to do this.
You can learn from the masters. Spend some time listening to and transcribing your favorite guitar solos. In time you will start to recognize simple patterns in even the most complex and intricate solos. This is how music is made, by repeating simple ideas. Long flowing phrases are common in bebop (one of my favorite styles) and I've worked though solos by Charlie Parker, Pat Martino, George Benson (the early years), etc. They are all great and my comment is not meant to be overly reductionist or take away from the "magic" in their playing but quite frankly there is a lot of simple 3 and 4 note phrases that are cascading through the changes.
It helps to understand the structure of the song you are playing to as that will help you formulate phrases, or fit the ones you know into the song. Take for example the Blues. The chords are I7, IV7, and V7 with some variation in them. And the changes come in the same place within the song, you have to know if its 12 or 8 bar blues etc. You can take your blues like and play it one the 1, then the 5 of each chord, or quickly move it from 1 to 5 to 8 (the octave). The "5" I'm referring to is the 5th degree of the I7 chord not the V7 chord, though the same lick would work there too. For example, in the C blues your long lick over C7 would be "some lick starting on C" + "same lick moved to G" + "moved up again to C 8va". Now the next chord is F7 and C is the 5th of that so you are already on the right spot to repeat that lick. Now you can move the same lick up or down to F, and back to C (which is the next chord). When the G7 comes around you can play the same lick on G and/or D. From there you can set yourself up to move the lick to G (which overlaps the C7) or walk it up from D to C which sounds cool too.
From the above example you can see that understanding how chords overlap (what common tones they have) is key to developing more long flowing lines. It may seem like a mystery at first but I'd reiterate that the best way to learn is by example. Get your hands on sheet music or TAB, or use your ear and transcribe, a solo that has these characteristics and start dissecting it looking for the simpler repetitive patterns. Then building one up using your own simple licks. In time you will develop the ability to "flow".
Sing! Try singing improvised melodies to yourself, in the shower or wherever you get spare time. The point isn't to be good at singing, the point is to get yourself fluently thinking in terms of melody, without mechanical constraints.
The second/concurrent step is to learn to play melodies you vocally/mentally improvise. If you know what a semitone sounds like, you can recognize a semitone in your melodies, and can translate that to the mechanical activity of moving up a fret. There are a couple of questions on this site relating to this, I'd recommend this answer about memorizing intervals in ear training, and what are the most effective ear training methods
Richard Strauss claimed that his method was to think up a simple one-measure figure (or riff); then he extended that figure to two measures by various means (repeat, sequence, inversion, retrograde, transposition, or juxtapose another, preferably contrasting, theme.)
Then he would proceed to use similar techniques to expand the first two measures to four. This four-measure phrase would be expanded to eight or even more commonly sixteen but similar extension methods or by developing a contrasting 4-measure theme and making an AABA or even AAAB pattern.
He would then uses the same techniques to expand again; here some measures could be added to a 4-measure phrase to extend to the theme or a measure could be removed to shorten things.
When improvising, one gets what one gets; when composing, one can edit the piece until something (hopefully better) results. (If one thinks really fast, one can edit during improvising by thinking a few measures ahead.)
There are some sources on the internet that can be used. More can be found through searches.