I had a similar problem and was able to solve it by upgrading the ML Agents package. According to Releases · Unity-Technologies/ml-agents · GitHub the only mismatch using the latest release was the com.unity.ml-agents and com.unity.ml-agents.extensions packages. Assuming you are currently able to start training successfully, you can determine all of the version information except for the C# packages immediately when running mlagents-learn. The version of the C# packages is also outputted on the command line as soon as the scene is connected.
So I did this rather than downgrade python, as I had tried that and it said my yaml had a lot of invalid fields and I’d rather upgrade than downgrade. I installed com.unity.ml-agents through the package manager but had to enable pre release builds to get the latest version. You may also need com.unity.ml-agents.extension package, which must be installed via github; see Unity does not recognise MLAgents namespace .
Then, if you get a bunch of errors in your code, you’ll have to do some editing since things change between versions, slight differences in function names, types and such:
See Struct ActionBuffers | ML Agents | 2.1.0-exp.1 for documentation, the dropdown menu in the top left lets you select your version.
Assuming this works, you should simply be able to retrain and drag the generated onnx file into your agent model field without errors.