Setting context pools acts differently between agent form and context pool form
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3554221. -->
Reported by: [tedbow](https://www.drupal.org/user/240860)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>I was playing around with setting context pools and trying to figure out how "always on" works.</p>
<p>Searching the code I noticed you could set context by either by one agent on its form(via ai_context_form_alter) or per pool for multiple agents. </p>
<p>On the per pool form AiAgentContextPoolForm, for each agent you can select 1 of "Not included", "Include when relevant" or "Always included"</p>
<p>but on the Agent form you select the same context for both "Assigned AI Contexts" and "Always include contexts"</p>
<p>So what I think this means is that using agent form the config `ai_context.agent_pools.agents` 1 agent can appear under both "contexts" and "always_include", but if using the AiAgentContextPoolForm, 1 context can only appear under 1 of these.</p>
<p>Side node: Trying to figure out the module I find</p>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br>$agents</span><span style="color: #007700">[] = [<br> </span><span style="color: #DD0000">'id' </span><span style="color: #007700">=> </span><span style="color: #0000BB">$agent_id</span><span style="color: #007700">,<br> </span><span style="color: #DD0000">'contexts' </span><span style="color: #007700">=> </span><span style="color: #0000BB">$contexts</span><span style="color: #007700">,<br> </span><span style="color: #DD0000">'always_include' </span><span style="color: #007700">=> </span><span style="color: #0000BB">$always</span><span style="color: #007700">,<br> ];<br></span><span style="color: #0000BB">?></span></span></pre></div>
<p>Confusing because under both "contexts" and "always_include" are context ids.<br>
If it is not too late to change this could it be changed to</p>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br>$agents</span><span style="color: #007700">[] = [<br> </span><span style="color: #DD0000">'id' </span><span style="color: #007700">=> </span><span style="color: #0000BB">$agent_id</span><span style="color: #007700">,<br> </span><span style="color: #DD0000">'relevancy_contexts' </span><span style="color: #007700">=> </span><span style="color: #0000BB">$contexts</span><span style="color: #007700">,<br> </span><span style="color: #DD0000">'always_included_contexts' </span><span style="color: #007700">=> </span><span style="color: #0000BB">$always</span><span style="color: #007700">,<br> ];<br></span><span style="color: #0000BB">?></span></span></pre></div>
<p>Because this is just a simple config array I have to search for <code>'contexts'</code> to figure out how this is being used.</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>If it is actually needed to be able to edit the same information in the 2 forms then make the UI the same between the 2 places.</p>
<p>One idea, create <code>AiAgentContextPoolForm::createAgentForm</code> as static function that could be called from both \Drupal\ai_context\Form\AiAgentContextPoolForm::buildForm and ai_context_form_alter</p>
<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>
> Related issue: [Issue #3567798](https://www.drupal.org/node/3567798)
issue