Agents have silent dependencies

Created on 26 March 2025, 20 days ago

Problem/Motivation

Currently, AI Agents includes a few agents that have dependencies on other modules that are not core dependencies of AI Agents (or it's dependants). This means there are agents that make use of services, classes, or entity types that are not available.

Steps to reproduce

Install AI Agents on a site that doesn't have node enabled. Try the Node Content Type Agent in the API explorer, you get a fatal error:

Error: Class "Drupal\node\Entity\NodeType" not found in Drupal\ai_agents\Plugin\AiAgent\ContentType->getNodeTypes() (line 489 of /var/www/html/docroot/modules/contrib/ai_agents/src/Plugin/AiAgent/ContentType.php).

Proposed resolution

We should introduce a mechanism for declaring module dependencies in the plugin definition and the plugin manager should check that module dependencies are met, discarding plugins where that is not the case.

User interface changes

N/A

API changes

New optional param in the plugin definition attribute.

📌 Task
Status

Active

Version

1.1

Component

Code

Created by

🇬🇧United Kingdom andrewbelcher

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @andrewbelcher
  • Merge request !68Resolve #3515453 "Agents have silent" → (Merged) created by MrDaleSmith
  • Pipeline finished with Failed
    18 days ago
    Total: 304s
    #459678
  • Pipeline finished with Failed
    18 days ago
    Total: 151s
    #459683
  • Pipeline finished with Success
    18 days ago
    Total: 163s
    #459687
  • 🇬🇧United Kingdom MrDaleSmith

    I'm not 100% convinced this is the right way to go about it, as we've got multiple "things" using "AI" that have multiple ways of telling Drupal they need specific modules to do it and it feels like a lot of complexity and duplication: certainly with this change, if I understand what's going on (which I can't guarantee) the isAvailable functionality feels pointless - if the dependencies required aren't available, the plugin will not instantiate so isAvailable() can't be called.

    But there's a MR for review and further discussion, anyway.

  • 🇩🇪Germany marcus_johansson

    For 1.1.x/config agents, I think the isAvailable method is redundant and can be covered completely by the method that runs the agent. For the coded agents, this change is in theory good. but as Paul writes the method is now completely redundant for our current agents. It could however be that there is some contrib/private agent that uses this to check for an executable or some other none-module dependency conditional, so we should keep it in to not have breaking changes until 2.0.x at least.

    Going forward its actually good if the the agent is allowed to run even if the necessary requirements are missing and then run into the tools exception or error message from execute and give back human readable reasons why it can't run a specific tool like "I can't seem to be able to get information about Views, because you haven't installed the Views module", "I can't look at your video, because FFmpeg is not installed on your server".

    Tested and RTBC for me, so I'll go ahead an merge.

Production build 0.71.5 2024