Make it possible to restrict the order of tools during agent executions
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3560681. -->
Reported by: [shashikanth171](https://www.drupal.org/user/3516867)
Related to !252
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>AI Agent can sometimes execute tools in an order that doesn't make any sense. We can avoid this by improving the prompt template, making it more verbose with trial and error.</p>
<p>Need to somehow allow configuration of each tool, to set which tool should be run prior to it. We can also expand it by including conditions like should be executed 1. only once, 2. first, 3. last etc.</p>
<p>Depending on the tool and use case, configuring the agent with such restrictions will reduce the chances of unintended hallucinations.</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<ul>
<li>Create an AI agent with multiple tools enabled (e.g., list_entity_types, create_content_type, save_content).</li>
<li>Run the agent with a task that requires tools to be used in a specific order.</li>
<li>Observe that the LLM may call tools in any order — it might attempt save_content before list_entity_types has gathered the needed context, or call a destructive tool multiple times.</li>
<li>There is no mechanism to control when tools become available to the agent across loop iterations, how many times they can be called, or which tools must run first.</li>
</ul>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<h3 id="summary-ui-changes">User interface changes</h3>
<h3 id="summary-api-changes">API changes</h3>
<h3 id="summary-data-model-changes">Data model changes</h3>
issue