Recreate AI Agents runner, but only for config entities
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3553408. -->
Reported by: [marcus_johansson](https://www.drupal.org/user/385947)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Currently the Agent runner has a lot of overhead because of the plugin agents in Drupal 1.0.0. Approximately 80% of the runner code, does not actually work with the config/ReACT agents.</p>
<p>For 2.0.0 we are moving the runner into AI Core and making it a lot simpler. First of all we know that since the agents are not workflows anymore, defining success is hard. This means that the agents returning different enum of its output status makes very little sense - the agent can have execution errors, otherwise it will return a text or a structured output. If you want to put a flag or a list of possible output statuses for orchesration you should use structured output for this.</p>
<p>So the base structure for the runner would be something like this:</p>
<pre>try {<br>$agent = \Drupal::service('agent_runner')<br> ->load('my_agent')<br> ->setChatInput(new ChatInput([new ChatMessage('What can you do?')))<br> ->execute();<br>}<br>catch(Exception $e) {<br> // Do something.<br>}<br>$output = $agent->getChatOutput();<br>$structured_output = $agent->getStructuredOutput(); // If available.</pre><p>Previous helper methods to get the seeded tools on any levels should still exist.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<ul>
<li>Move the running code into its own runner service.</li>
<li>Create interfaces and sub-services for a lot more, so more developers can start working on it - this means that running tools, using sub agents, setting events etc. is abstracted.</li>
<li>Make sure that any agent run, can be reinstated and called from any loop, including sub-agent loops.</li>
<li>Right now a temporary run is stored in privatetempstorage - we should think about moving that into the file system if secure.</li>
</ul>
<p>This issue is dependent on <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-4"><a href="https://www.drupal.org/project/ai/issues/3553398" title="Status: Postponed">#3553398: Move AI Agents Entity to AI Core and create a better structure</a></span>.</p>
> Related issue: [Issue #3553398](https://www.drupal.org/node/3553398)
issue