# Learning Agents issue with SetupCompletions

**URL:** <https://forums.unrealengine.com/t/learning-agents-issue-with-setupcompletions/2490324>\
**Category:** C++\
**Tags:** unreal-engine, Machine-Learning, Learning-Agents, CPP\
**Created:** [May 4, 2025, 6:27pm UTC](https://forums.unrealengine.com/t/learning-agents-issue-with-setupcompletions/2490324 "2025-05-04T18:27:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marsal02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Marsal02](https://forums.unrealengine.com/u/Marsal02)\
**Post date:** [May 4, 2025, 6:27pm UTC](https://forums.unrealengine.com/t/learning-agents-issue-with-setupcompletions/2490324/1 "2025-05-04T18:27:29Z")

</div>

Hi so I am trying to create an AI that would be basically an Enemy archer that would learn how to shoot enemies that are moving continuously in a room I am using Learning Agents on 5.3.2, also using C++. My issue is that it will generate the first iteration results, it will run a little bit more, and will give me this error: Agent with id x has completed episode and will be reset but has not generated any experience. I am having like 7 agents. This is how my SetupCompletion looks like:

```auto
void ULearningAgentsTrainerR::SetupCompletions_Implementation()
{
    TimeCompletion = UTimeElapsedCompletion::AddTimeElapsedCompletion(
        this,
        FName("TimeCompletion"),
        30.0f, 
        ELearningAgentsCompletion::Truncation 
    );
}

```

And this is my SetCompletions implementation:

```auto
void ULearningAgentsTrainerR::SetCompletions_Implementation(const TArray<int32>& AgentIds)
{
    for (int32 AgentId : AgentIds)
    {
        float& Timer = EpisodeTimers.FindOrAdd(AgentId);
        Timer += GetWorld()->DeltaTimeSeconds;
        TimeCompletion->SetTimeElapsedCompletion(AgentId, Timer);
    }
}

```

And basically the error will get spammed, and my ResetAgents method will get called everytime, which basically will teleport my enemies continuously. I would really appreciate your help, really don’t know how to implement this SetupCompletions and SetCompletions, if you have any advice, it would be verry apreaciated.

---

<div class="post-metadata">

**Author:** ![Deathcalibur](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/deathcalibur/32/1037610_2.png) [@Deathcalibur](https://forums.unrealengine.com/u/Deathcalibur)\
**Post date:** [May 12, 2025, 1:52pm UTC](https://forums.unrealengine.com/t/learning-agents-issue-with-setupcompletions/2490324/2 "2025-05-12T13:52:45Z")

</div>

Make sure you reset the agent’s timer during ResetAgents, otherwise you’ll keep completing constantly.
