I had an almost identical situation on a 97 Outback with 2.2 swap.
Ended up being the O2 Sensor.
I can't find any info from Subaru about how the O2 affects ECU's timing calculations. But in this one case, for me, the timing was randomly retarding to less 13~15 degrees under light throttle cruising (when it should be more like 20~35)
When the timing would pull back, the car would feel sluggish, no throttle response. Although for this case it was not a bucking, jerking loss of power. More like when you get to a slight hill and try to give a little more throttle, nothing would happen for several seconds (timing at ~15) then would kick in (timing jumps back up to 30 or so) and then acceleration would feel normal again.
Putting in a brand new Denso O2 sensor seems to have stopped that issue and car drives normal now. Timing stays where it should.