Maybe the tool could live in the ai_search module?
michaellander → created an issue.
michaellander → created an issue.
The Tool Explorer module has been added, can can be accessed at /admin/config/tool/explorer.
Good to know! I'm proposing removing the _sleep() method override in this particular case, so win-win.
Also worth noting, if you look at \Drupal\Core\TypedData\ListDataDefinition, we do not unset itemDefinition during serialization. Which means there's a discrepancy between how they are handling their child definitions.
I've been experimenting with some different versions of just that, though I do believe it differs from the agent tool dynamic discussion.
Instead of giving the LLM all the tools, I just exposed 3 tools: tool_list, tool_plan, and tool_execute. The LLM can use list to find the right one, plan to make sure it understands the tool and execute to actually call the tool. I had pretty good results, though I only pushed it so far. I think as the library of tools grows, we can definitely get creative here.
I could certainly use some help on the categorization/grouping side. I want to introduce the concept of 'Toolsets', but again, outside the scope of this conversation.
I'm of the belief that the overlap between Agents and Tools is pretty significant and we could potentially reuse some of those parts from Tool API for our agent approach. I really see an agent as a composite tool, that just uses AI to determine which(subtools) to use. It also has the benefit of additional context/prompting/etc that a single individual tool is lacking.
I put together an example of what an agent definition/plugin could look like:
namespace Drupal\ai_agents\Plugin\agent\Agent;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\tool\TypedData\EntityInputDefinition;
/**
* Plugin implementation of an example agent.
*/
#[Agent(
id: 'example',
label: new TranslatableMarkup('Example'),
description: new TranslatableMarkup('Does example stuff'),
prompt: '.......',
provider: Provider::SITE_DEFAULT,
max_retries: 3,
input_definitions: [
'entity' => new EntityInputDefinition(
data_type: 'entity:node',
label: new TranslatableMarkup("Node"),
required: TRUE,
description: new TranslatableMarkup("The node entity"),
),
],
tools: [
// Attach by Tool ID.
'tool_debug.example_tool',
// Attach with additional configuration.
Agent::attachTool(
id: 'tool_debug.example_tool_2',
prompt: '...',
),
// Attach a Sub-Agent.
Agent::attachSubAgent(
id: 'tool_debug.example_sub_agent',
tools: [
'tool_debug.example_tool_3',
],
),
],
output_definitions: [
'updated_entity' => new EntityInputDefinition(
data_type: 'entity:node',
label: new TranslatableMarkup("Node"),
required: TRUE,
description: new TranslatableMarkup("The node entity"),
),
],
)]
class Example extends AgentBase {
// Nothing necessarily has to be here if you just want it to use the tools.
}
By getting the definition in a good place, where one can easily define an agent without any additional behavior in the class, and allow prompts/overrides/constraints/etc. We can really nail the agent pattern and then the UI should fall into place rather easily.
See 📌 Remove 'Exists' condition tools Fixed .
michaellander → changed the visibility of the branch 3550861-tools-create-fieldadd to hidden.
michaellander → changed the visibility of the branch 3556855-create-distinction-between to hidden.
Accidentally pushed into 1.0.x directly. That's my bad.
Do we need to add toArray() to the \Drupal\Core\TypedData\DataDefinitionInterface()? I'm needing either toArray() or offsetGet() but the former isn't under contract.
michaellander → made their first commit to this issue’s fork.
michaellander → made their first commit to this issue’s fork.
This fixes this specific issue, but we should probably add test coverage and try more versions of this(maps for example) with constraints.
I would like to opt-in this module:
https://www.drupal.org/project/tool →
It has 48 total issues, and all maintainers agree we are ready to try GitLab issues. We understand we cannot revert this change and there may be some unexpected issues as early adopters.
There are a few PHPStan flags that I'm not sure the best way to fix. The one about using \Drupal to get the tempstore service is intentional, however, as I would like to replace the token stuff with a common API that works across modules and don't want to tie the tempstore service into the dependency injection until a unified solution is in place.
This branch depends on 📌 Determine path forward for turning Attributes into JSON schema Active , which I'm hoping to have fixed shortly.
I pushed up the normalizer's I'm testing, they are working but are not complete.
Worth noting, one of the changes is that the exhaustive tool list would not live on the page but instead in a modal/tray. So the tools displayed here are only the ones added to the agent. So while the amount of tools will grow, the amount used on the agent will just be a small subset of the total amount of tools. I'm open to putting them on a tab, I just don't think it's going to be a significant issue either way.
I was running into issues where the Gemini CLI schema validation is more strict than other clients. In my case, there were additional schema properties such as 'name' that I had to remove recursively and a missing parameters property in some cases.
This was happening when using MCP with AI Function Calls, and I did not get to go further than that yet.
michaellander → created an issue.
michaellander → created an issue.
I have a version of this for Tool API. It was put on the back burner temporarily but I'm delving back into it. I think we need to connect it in a way that leaves it up to the tools plugin to determine the configuration form for per-instance configuration. For example, when adding an existing function call, we can use a form similar to what we have currently. When adding an agent tool, the experience may differ, when adding a Tool API tool, we can inherit the refinement form from that module. If there are specific form elements that you want to persist across all tools, then we can just embed the per tool-type form within a shared form.
That's my opinion right now at least.. I'll work on getting the Tool API version back up and running so you can see it.
I've updated the original topic to reflect the solution that went into the module. I think overall it's a win-win in that we can lean on data type validations, but also communicate those dependencies to UI/AI/etc.
Also noting, we are using the AI normalizer in a few places currently without the dependency in place for Tool API, which I'm not intended on adding. That makes this extra important to solve independently of any one tool caller.
Fixed. The solution I landed on varies slightly from the original post. Will get that updated shortly.
michaellander → changed the visibility of the branch 3545828-introduce-dynamic-tools to hidden.
Added an initial set of tools, though some of which are going to be dependent on 🌱 Introduce Dynamic Tools Active . We can still start building them as it won't cause much backtracking, just additional refinement.
If these go quick or we get more help, we can definitely consider doing even more from:
https://docs.google.com/spreadsheets/d/18knLUFa2uUll_nOe4yGFPjDBQmDvqJtM...
michaellander → created an issue.
michaellander → created an issue.