Using a keyboard which is being played in the set as my master controller has always caused endless problems. Midi clocking loops, stuck notes, and more. I really feel for you. Especially because this really just should work.
Investigate the many sync options for the P6
Since midi must go OUT to the Pyramid, and return IN to the P6 you have a loop.
Try setting the internal sync on the P6 to something other than midi, like USB or OFF if that’s available.
Turn CC control on the P6 to internal, or even OFF if you can.
Now for clock out settings, this needs to be turned OFF.
Now you should only be getting a loop for the actual midi notes being channelized on the P6 channel.
This won’t be a problem for other instruments, but it will be a drag when actually playing the P6
On the Pyramid try messing around with the midi input and output settings and see if maybe Midi Out (vs Midi Out + Thru) makes a difference? Take a look at Midi Echo as well. You may want to be sure this is OFF.
I was having a frustrating loop in my efforts to add a fader controller to the start of the cain (OUT to the IN of the Pyramid) and it worked only with MIDI out + Thru turned on. But the sticking notes problem wasn’t ok, so I moved the controller further down the chain to just before the Octatrack (it is meant to control) and split the midi so midi comes for the Octotrack, and is split so that the midi out of the controller is merged with the midi input from the pyramid and it works well without doubling, or sticking.
Great for me, but you’re struggling with a different issue. I hope looking at these settings, and finding a way to break the loop works out!