Performance Checklist
When to Use
Run through this when a site has many Tool API tools or tools run in loops. The costs sit in instantiation, listing and schema building. Each item links to the page that owns the rule.
Version: applies to
drupal/tool1.0.0-beta11 (beta; no security advisory coverage). Paths are undermodules/contrib/tool/.
Checklist
- [ ]
create()andcheckRequirements()are cheap: no HTTP calls, no entity queries. Drush listings instantiate and check every listed tool → checkRequirements - [ ] Catalogs filter with static
ToolManager::checkPermission(), not by instantiating tools → Access Control - [ ]
drush crruns after tool changes, thendrush tool:listconfirms discovery; one bad definition breaks every tool → Defining a Tool - [ ] Expensive
Readtools cache insidedoExecute(); Tool API does not cache results → doExecute and ExecutableResult - [ ] List tools take paging inputs with
Rangeconstraints → doExecute and ExecutableResult - [ ] Agents get a scoped tool list, since every connector tool adds a schema → Calling a Tool from the AI Module
- [ ] Site-derived enums over 50 entries are expected to disappear from the schema → Input Definitions
- [ ]
getFormattedResult()is called freely afterexecute(); it is memoized → Calling a Tool from PHP
Common Mistakes
- Returning full entity field dumps to an agent → token cost and data exposure; return the fields the task needs
See Also
- checkRequirements
- Reference:
modules/contrib/tool/src/Drush/RequirementStatus.php,modules/contrib/tool/src/Tool/ToolManager.php