Add normalization for required tools
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3546649. -->
Reported by: [marcus_johansson](https://www.drupal.org/user/385947)
Related to !912
>>>
<p>--- AI TRACKER METADATA ---<br>
Update Summary: Changes to make it easier to input structured output.<br>
Check-in Date: MM/DD/YYYY (US format) [When we should see progress/get an update]<br>
Due Date: MM/DD/YYYY (US format) [When the issue should be fully completed]<br>
Blocked by: [#XXXXXX] (New issues on new lines)<br>
Additional Collaborators: @username1, @username2<br>
AI Tracker found here: <a href="https://www.drupalstarforge.ai/">https://www.drupalstarforge.ai/</a><br>
--- END METADATA ---</p>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>One of the issue that can happen quite often in Agents is that even with well constructed prompts, the actual choices made by the agent might not be consistent enough for a production ready agents.</p>
<p>If you for instance know that tool A, should always run first no matter what or if you know that tool B always runs after tool A has been run, we should have a feature to force this.</p>
<p>This can be done in certain providers via tool choice.</p>
<p>See for instance:</p>
<ul>
<li>OpenAI: <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-tool_choice">https://platform.openai.com/docs/api-reference/chat/create#chat-create-tool_choice</a></li>
<li>Ollama (Tool Calls): <a href="https://ollama.readthedocs.io/en/api/#parameters_1">https://ollama.readthedocs.io/en/api/#parameters_1</a></li>
<li>Groq: <a href="https://console.groq.com/docs/tool-use">https://console.groq.com/docs/tool-use</a></li>
</ul>
<p>We should add a normalization value for this in the ChatInput object.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<ul>
<li>Research the providers, to see if there is anything outside of how OpenAI does it, that needs implementation.</li>
<li>(Suggestion) Create a ToolChoice object (and maybe interface), that takes Mode and Allowed Tools, where Mode is optional and set to auto by default.</li>
<li>Add to the ChatInput a getToolChoice and setToolChoice. Make sure that either setToolChoice can take NULL or that we also have a removeToolChoice, since a ChatInput might be changed in another loop.</li>
<li>(Optional) Since we are getting so many new getters that are not part of the constructors, we should let it return it self, so you can chain an object.</li>
<li>Document it</li>
</ul>
issue