Hi, I have a very similar question, so I decided just to continue here instead of creating a new topic. Let me start from describing the high level idea of what I’m trying to accomplish.
I deal with RL setting. There’re two different variables encoded as different SDRs: state s_t and action a_t.
So, I have a stateaction sequence [s_0, a_0, s_1, a_1, s_2, ..] and I want to make an agent, which learns two things.

To memorize the sequence of states [s_0, s_1, s_2, .. ].
Here’s also an important relation between states and actions  next state s_{t+1} depends on both s_t and a_t. This means there’s a hidden prediction function f_s: (s_t, a_t) \rightarrow s_{t+1} I want to learn.
TM perfectly suits for this problem, but it requires to add an external action context a_t to depolarization phase, which I don’t know how to do.

To memorize the sequence of actions [a_0, a_1, a_2, ..].
Again, TM is ideal candidate for this problem, but… a hidden prediction function f_a depends only on state s_{t+1}, but not on action a_t, i.e. f_a: s_{t+1} \rightarrow a_{t+1}.
This means that depolarization phase should only depend on external context instead of inner distal connections, which is another problem I don’t know how to solve with htm.core
TM.
Right now I have a solution with just one TM, encoding sequences [(s_0, a_0), (s_1, a_1),..], i.e. where stateaction pair is concatenated and considered as a whole unit. It’s a close solution, but not exactly what I want  it has some limitations that I want to get rid of.
The main problem with the current solution is that distal synapses s \rightarrow s, s \rightarrow a, a \rightarrow s, a \rightarrow a are all mixed up in segments.
I want to split them into 4 different kinds of segments and then to have a fine grained control on each of these kinds of segments  max number of segments, max size of segment, their activation threshold.
The possible solution to these problems could be if TM had these specific properties:
 you can specify any arbitrary number of external contexts to TM
 aka “distal external” context, but I’m not sure that’s a correct naming
 each context is represented as SDR
 I guess it’s probably implemented in TM, but I haven’t found any examples or guides on how to use this functionality.
 also each context induces different kind of depolarizations defined by it’s own activation threshold
 i.e. you can specify unique activation thresholds for both inner distal connections and each of the external contexts
 then all different kinds of depolarizations are merged by AND operation  i.e. the cell becomes depolarized only if it has all kinds of depolarizations
 consequently you can specify max number of segments and max size of each segment not only for inner distal connections, but also for each of the provided external contexts.
So, I’d like to know is it already implemented in the current version of TM and how to use it? Or maybe it’s somehow planned to be done?
If not, then maybe you saw similar cases with alternative solutions.
FYI: I use python binding to htm.core
and I haven’t dug C++ sources yet. Also I know the details of TM/SP implementations almost only through BAMI chapters.
p.s. If anything is not clear in my post, I’ll be happy to edit it and add some clarifications. Thanks!