LearningAgentsInteractor::SetActionVector , size check uses wrong getter

Hi,

Spotted what looks like a copy-paste bug in Epic’s LearningAgentsInteractor.cpp inside SetActionVector:

https://github.com/EpicGames/UnrealEngine/blob/13b6acfd6224d13e37e5c75e94415544116ca945/Engine/Plugins/Experimental/LearningAgents/Source/LearningAgents/Private/LearningAgentsInteractor.cpp#L673

if (ActionVector.Num() != GetObservationVectorSize())

{

UE_LOG(LogLearning, Error, TEXT("%s: Action Vector size incompatible. Got %i, expected %i."),

*GetName(), ActionVector.Num(), GetActionVectorSize());

return;

}

The condition compares ActionVector.Num() against GetObservationVectorSize(), but the error message logs GetActionVectorSize(), which is what the comparison should be using. Looks like it was copy-pasted from SetObservationVector (a few methods above) and the condition was missed during the rename.

Practical impact:

  • If ObservationVectorSize == ActionVectorSize by coincidence, the check passes anyway → nothing visible breaks.

  • If the sizes differ (the common case once observations and actions are non-trivial), the function either:

    • rejects a correctly-sized action vector when ActionVectorSize > ObservationVectorSize, or

    • silently accepts a malformed action vector and then UE::Learning::Array::Copy reads/writes past one of the buffers when ActionVectorSize < ObservationVectorSize.

The second case is the dangerous one silent buffer over/under-read on the ActionVectors[AgentId] row. No crash in most builds, just garbage actions getting fed to the policy.

The fix is a one-line change:

if (ActionVector.Num() != GetActionVectorSize())

Easy to repro: register an interactor where observation and action sizes differ, then call SetActionVector with a properly-sized action vector it’ll get rejected.

Worth filing upstream to Epic, and patching locally in the meantime if you’re hitting the asymmetric-size path.

Cheers

1 Like

Thanks! This will be fixed in UE 5.8