# AIPerceptionStimuliSourceComponent Cook Indeterminism 

**URL:** <https://forums.unrealengine.com/t/aiperceptionstimulisourcecomponent-cook-indeterminism/2672619>\
**Category:** Platform & Builds\
**Tags:** unreal-engine, Epic-Pro-Support, question\
**Created:** [September 25, 2025, 5:37pm UTC](https://forums.unrealengine.com/t/aiperceptionstimulisourcecomponent-cook-indeterminism/2672619 "2025-09-25T17:37:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [September 25, 2025, 5:37pm UTC](https://forums.unrealengine.com/t/aiperceptionstimulisourcecomponent-cook-indeterminism/2672619/1 "2025-09-25T17:37:25Z")

</div>

Hi we are running into an issue with AIPerceptionStimuliSourceComponent where it is causing our cooks to become indeterministic

A cook with Diff only shows:

-[1] /script/aimodule/aiperceptionstimulisourcecomponent Default\_\_Ooze3\_Duplicate\_C/AIPerceptionStimuliSource Super: NULL, Template: /Game/DesignAssets/Population/NPC/Monster/Aberration/Ooze/Ooze3.default\_\_ooze3\_c/aiperceptionstimulisource, Flags: 262185, Size: 17, FilterFlags: 0

+[1] /script/aimodule/aiperceptionstimulisourcecomponent Default\_\_Ooze3\_Duplicate\_C/AIPerceptionStimuliSource Super: NULL, Template: /Game/DesignAssets/Population/NPC/Monster/Aberration/Ooze/Ooze3.default\_\_ooze3\_c/aiperceptionstimulisource, Flags: 262185, Size: 10, FilterFlags: 0

My hunch here is that is related to the RemoveAndSwap [here](https://github.com/EpicGames/UnrealEngine/blob/ue5-main/Engine/Source/Runtime/AIModule/Private/Perception/AIPerceptionStimuliSourceComponent.cpp#L27), but this also out of my realm of expertise and im not sure how to debug this. Ive also attached some additional relevant logs to the ticket that may help

---

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [September 25, 2025, 5:37pm UTC](https://forums.unrealengine.com/t/aiperceptionstimulisourcecomponent-cook-indeterminism/2672619/2 "2025-09-25T17:37:30Z")

</div>

**Steps to Reproduce**  
Add AIPerceptionStimuliSourceComponent to a blueprint. Do an initial cook with -cookincremental, then do another cook -cookincremental and -diffonly

---

<div class="post-metadata">

**Author:** ![Matt.Peters](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Matt.Peters](https://forums.unrealengine.com/u/Matt.Peters)\
**Post date:** [October 8, 2025, 8:17pm UTC](https://forums.unrealengine.com/t/aiperceptionstimulisourcecomponent-cook-indeterminism/2672619/3 "2025-10-08T20:17:04Z")

</div>

The export is possibly becoming smaller (17 bytes down to 10 bytes) because in the second cook it has the same value for one of its properties as its archetype does, and delta serialization causes the serialization of the field to be skipped.

I agree the RemoveAllSwap is suspicious and is the first thing to test. If that’s the problem, then the repro case is more complicated than just creating a blueprint (needs a blueprint hierarchy, plus some missing Senses arguments), so I’d like to have you try out a fix rather than trying to recreate it:

Can you try a code change:

Add a NormalizeSenses function. Move the code in OnRegister that calls RemoveAllSwap into NormalizeSenses. Modify NormalizeSenses to also call NormalizeSenses on the archetype object. Also call NormalizeSenses from PreSave:

Engine\Source\Runtime\AIModule\Classes\Perception\AIPerceptionStimuliSourceComponent.h

```auto
class UAIPerceptionStimuliSourceComponent : public UActorComponent
{
...
public:
 
	AIMODULE_API UAIPerceptionStimuliSourceComponent(const FObjectInitializer& ObjectInitializer);
 
// NewLines
	AIMODULE_API virtual void PreSave(FObjectPreSaveContext SaveContext) override;
	AIMODULE_API void NormalizeSenses();
// EndNewLines
...
}

```

Engine\Source\Runtime\AIModule\Private\Perception\AIPerceptionStimuliSourceComponent.cpp

```auto
...
#include "Perception/AIPerceptionStimuliSourceComponent.h"
#include "Perception/AIPerceptionSystem.h"
// NewLines
#include "UObject/ObjectSaveContext.h"
// EndNewLines
#include "VisualLogger/VisualLogger.h"
...
void UAIPerceptionStimuliSourceComponent::OnRegister()
{
	Super::OnRegister();
 
#if WITH_EDITOR
	// when in the editor world we don't remove the null entries
	// since those can get changed to something else by the user
	if (!GIsEditor || GIsPlayInEditorWorld)
#endif // WITH_EDITOR
	{
// ModifiedLines
		NormalizeSenses();
// EndModifiedLines
	}
 
	if (bAutoRegisterAsSource)
	{
		RegisterWithPerceptionSystem();
	}
}
...
// NewLines
void UAIPerceptionStimuliSourceComponent::PreSave(FObjectPreSaveContext SaveContext)
{
	Super::PreSave(SaveContext);
	NormalizeSenses();
}
 
void UAIPerceptionStimuliSourceComponent::NormalizeSenses()
{
#if WITH_EDITOR
	UAIPerceptionStimuliSourceComponent* Archetype = Cast<UAIPerceptionStimuliSourceComponent>(GetArchetype());
	if (Archetype)
	{
		Archetype->NormalizeSenses();
	}
#endif
	RegisterAsSourceForSenses.RemoveAllSwap([](const TSubclassOf<UAISense>& SenseClass) {
		return SenseClass == nullptr;
		});
}
// EndNewLines

```

If that fixes the issue, I will submit it for 5.8 (and will let you know of any further changes from code review).

If not, then I’ll look for another issue.
