Setting AI contexts has no effect on some agents
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3554616. --> Reported by: [tedbow](https://www.drupal.org/user/240860) Related to !10 >>> <p>[Tracker]<br> <strong>Update Summary: </strong>[One-line status update for stakeholders]<br> <strong>Short Description: </strong>[One-line issue summary for stakeholders]<br> <strong>Check-in Date: </strong>MM/DD/YYYY<br> <strong>Additional Collaborators: </strong>@tedbow @kristen pol<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 found that setting the Context pools only affects some agents</p> <p>For instance the Content Type Agent, id content_type_agent_triage, provided by the AI Agents module is not affected by context. </p> <p>Debugging I have found that \Drupal\ai_context\Plugin\AiFunctionCall\AiAgentWrapperWithContext::execute is never called with content_type_agent_triage as the agent Id. Because of this when \Drupal\ai_context\EventSubscriber\SystemPromptSubscriber::onPreSystemPrompt is called there is not ai_context token and the context is not added to the prompt</p> <p>I am investigating why this happens and will update when I figure it out. If anyone else knows please comment. </p> <p>I also tested with AI Canvas. The canvas_component_agent agent works and AiAgentWrapperWithContext::execute is called but canvas_ai_orchestrator does not work. </p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <ol> <li>Add a simple context call "testing"<br> <blockquote><p>This is site is still in testing. For all text generated add "just testing:" as a prefix</p></blockquote> </li> <li>go to admin/config/ai/ai-context/pools/content_type_agent_triage/edit</li> <li>set the "testing" context to "always include"</li> <li>Go to admin/config/ai/agents/explore?agent_id=content_type_agent_triage (ai_agents_explorer must be enabled </li><li>Use the prompt Make a "blog" content type . The description should be text that explains what a "blog" is </li></ol> <p>It should make the content type but "just testing:" is not added before the description.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Moving more logic into \Drupal\ai_context\EventSubscriber\SystemPromptSubscriber::onPreSystemPrompt seems to solve this but there may be reasons not to do this</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>
issue