Refine function call context based on value restrictions
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3515670. -->
Reported by: [andrewbelcher](https://www.drupal.org/user/655282)
Related to !72
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Configuring tools for an agent supports restricting or forcing of context values. However, the definition of the function call that is sent to the LLM remains the same. This means that the LLM can think it's providing a different value that what's used (eg in the case of forced) or be unaware of restrictions to values it can provide. </p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<ul>
<li>Context with forced values should be included as a <code>constant</code> (depends on <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/ai/issues/3516052" title="Status: Closed (fixed)">#3516052: Add support for constants in AI function call schema</a></span>).</li>
<li>The list of allowed values should be included with an <code>enum</code> list. </li>
<li>These should be implemented by modifying the context definitions.</li>
<li>Validation should be switched to validating context, with errors reported back to the LLM appropriately.</li>
</ul>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>N/A</p>
<h3 id="summary-api-changes">API changes</h3>
<p>N/A</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<p>N/A</p>
issue