Skip to content

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/tool 1.0.0-beta11 (beta; no security advisory coverage). Paths are under modules/contrib/tool/.

Checklist

  • [ ] create() and checkRequirements() 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 cr runs after tool changes, then drush tool:list confirms discovery; one bad definition breaks every tool → Defining a Tool
  • [ ] Expensive Read tools cache inside doExecute(); Tool API does not cache results → doExecute and ExecutableResult
  • [ ] List tools take paging inputs with Range constraints → 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 after execute(); 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