buildTools function

List<Tool> buildTools(
  1. Genkit ai,
  2. ToolRuntime runtime
)

Builds the tools exposed to the agent.

Tools that cannot work in this session (PowerShell off Windows, MCP without an adapter) are left out so the model does not waste turns on them.

Implementation

List<Tool> buildTools(Genkit ai, ToolRuntime runtime) {
  final mcpAdapter = runtime.mcpResourceAdapter;
  return <Tool>[
    createReadTool(ai, runtime: runtime),
    createEditTool(ai, runtime: runtime),
    createWriteTool(ai, runtime: runtime),
    createGlobTool(ai, runtime: runtime),
    createGrepTool(ai, runtime: runtime),
    createBashTool(ai, runtime: runtime),
    if (Platform.isWindows) createPowerShellTool(ai, runtime: runtime),
    createAskUserQuestionTool(ai, runtime: runtime),
    createTaskCreateTool(ai, runtime: runtime),
    createTaskUpdateTool(ai, runtime: runtime),
    createTaskListTool(ai, runtime: runtime),
    createSleepTool(ai, runtime: runtime),
    if (mcpAdapter != null) ...<Tool>[
      createListMcpResourcesTool(ai, runtime: runtime, adapter: mcpAdapter),
      createReadMcpResourceTool(ai, runtime: runtime, adapter: mcpAdapter),
    ],
  ];
}