ai_context_ai_function_call_info_alter does not work with contexts only set via "always_include"
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3554277. --> Reported by: [tedbow](https://www.drupal.org/user/240860) Related to !9 >>> <p>[Tracker]<br> <strong>Update Summary: </strong>ai_context_ai_function_call_info_alter does not work with contexts only set via "always_include"<br> <strong>Short Description: </strong>ai_context_ai_function_call_info_alter does not work with contexts only set via "always_include"<br> <strong>Check-in Date: </strong>MM/DD/YYYY<br> <em>Metadata is used by the <a href="https://www.drupalstarforge.ai/" title="AI Tracker">AI Tracker.</a> Docs and additional fields <a href="https://www.drupalstarforge.ai/ai-dashboard/docs" title="AI Issue Tracker Documentation">here</a>.</em><br> [/Tracker]</p> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>I was testing with Drupal Canvas setting some of its agents to "always included". I noticed that `ai_context_ai_function_call_info_alter` was ignoring this which is stored as always_include</p> <p>see</p> <div class="codeblock"> <pre><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br></span><span style="color: #007700">if (!empty(</span><span style="color: #0000BB">$map</span><span style="color: #007700">[</span><span style="color: #DD0000">'id'</span><span style="color: #007700">]) &amp;&amp; !empty(</span><span style="color: #0000BB">$map</span><span style="color: #007700">[</span><span style="color: #DD0000">'contexts'</span><span style="color: #007700">])) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">$agentsWithPools</span><span style="color: #007700">[</span><span style="color: #DD0000">'ai_agents::ai_agent::' </span><span style="color: #007700">. </span><span style="color: #0000BB">$map</span><span style="color: #007700">[</span><span style="color: #DD0000">'id'</span><span style="color: #007700">]] = </span><span style="color: #0000BB">TRUE</span><span style="color: #007700">;<br>&nbsp;&nbsp;&nbsp; }<br></span><span style="color: #0000BB">?&gt;</span></span></pre></div> <p>Therefore these agents didn't have AiAgentWrapperWithContext set below</p> <p>Also see my related comment on <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/ai_context/issues/3554221" title="Status: Closed (fixed)">#3554221: Setting context pools acts differently between agent form and context pool form</a></span> that keys <code>contexts</code> and <code>always_include</code> are confusing because these both actually store context ids.</p> <p>I think if that wasn't the case this code would be more obvious as to what it is doing</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Take into account "always_include"</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 #3554221](https://www.drupal.org/node/3554221)
issue