Fatal Error on enabling: "ai_agent" entity type does not exist
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3516448. -->
Reported by: [mrdalesmith](https://www.drupal.org/user/2612656)
Related to !101 !71
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Using the curent dev version of the module on a clean Drupal 10 install, I get the following fatal error trying to turn the AI Agents module on through the UI:</p>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br>The website encountered an unexpected error</span><span style="color: #007700">. Try </span><span style="color: #0000BB">again later</span><span style="color: #007700">.<br><br></span><span style="color: #0000BB">Drupal</span><span style="color: #007700">\</span><span style="color: #0000BB">Component</span><span style="color: #007700">\</span><span style="color: #0000BB">Plugin</span><span style="color: #007700">\</span><span style="color: #0000BB">Exception</span><span style="color: #007700">\</span><span style="color: #0000BB">PluginNotFoundException</span><span style="color: #007700">: </span><span style="color: #0000BB">The </span><span style="color: #DD0000">"ai_agent" </span><span style="color: #0000BB">entity type does not exist</span><span style="color: #007700">. </span><span style="color: #0000BB">in Drupal</span><span style="color: #007700">\</span><span style="color: #0000BB">Core</span><span style="color: #007700">\</span><span style="color: #0000BB">Entity</span><span style="color: #007700">\</span><span style="color: #0000BB">EntityTypeManager</span><span style="color: #007700">-></span><span style="color: #0000BB">getDefinition</span><span style="color: #007700">() (</span><span style="color: #0000BB">line 142 of core</span><span style="color: #007700">/</span><span style="color: #0000BB">lib</span><span style="color: #007700">/</span><span style="color: #0000BB">Drupal</span><span style="color: #007700">/</span><span style="color: #0000BB">Core</span><span style="color: #007700">/</span><span style="color: #0000BB">Entity</span><span style="color: #007700">/</span><span style="color: #0000BB">EntityTypeManager</span><span style="color: #007700">.</span><span style="color: #0000BB">php</span><span style="color: #007700">).<br></span><span style="color: #0000BB">?></span></span></pre></div>
<p>This appears to be related to code added on 11 March to src/PluginManager/AiAgentManager.php, specifically the </p>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br>$this</span><span style="color: #007700">-></span><span style="color: #0000BB">mergeAgentConfigurations</span><span style="color: #007700">();<br></span><span style="color: #0000BB">?></span></span></pre></div>
<p>This seems to be trying to load the ai_agent entity storage handler before the ai_agent entity type exists? Presumably the plugin manager is getting created before the module has fully installed? </p>
issue