---
question: How do I give a module's agent its tools?
kind: task
via_web: na
via_cli: na
via_python: available
via_api: na
via_config: na
ref_python: tools=[...]
prereq: The agent is a module agent, built by `create_agent`. See [Create an agent](/capabilities/build/agents/creating-an-agent?via=python).
next:
  - /capabilities/build/agents/add-sub-agents
  - /capabilities/build/agents/test-an-agent
  - /capabilities/build/tools/overview
---

# Give it tools

A tool is a function the model can call. A module agent takes its tools when it is built: the module collects them in `on_initialized` and passes them to `create_agent`. They come from the module's workflows and pipelines, from other modules' agents, or from plain functions. A workspace agent has none.

## Web UI

Not applicable. Edit Agent does not attach tools, and a workspace agent has none: pass them to `create_agent` with the Python steps.

## CLI

Not applicable. There is no `abi new tool` command, and no command attaches a tool: use the Python steps.

## Python

### Get tools from a workflow or a pipeline

The module builds its `Workflow` and `Pipeline` classes after `on_initialized`. Build them earlier with `build_processes()`, then ask one for its tools:

```python title="src/research/__init__.py"
    async def on_initialized(self) -> None:
        await self.build_processes()
        tools = self.get_workflow_instance("customers_workflow").as_tools()
        tools += self.get_pipeline_instance("orders_pipeline").as_tools()
```

The name is the snake-case slug of the class name (`CustomersWorkflow` is `customers_workflow`). Each class gives one tool, named after that slug, described by its docstring and taking its parameters model. `as_tools()` needs the `naas-abi-sdk[agents]` (or `[agent]`) extra. See [Create a workflow](/capabilities/build/agents/creating-a-workflow).

### Or write a function

Any LangChain tool works. The model picks a tool from its name and docstring:

```python title="agents/ReviewerAgent.py"
from langchain_core.tools import tool


@tool
def count_words(text: str) -> int:
    """Count the words in a text."""
    return len(text.split())
```

An integration is a plain class the module calls: wrap the calls the agent needs in a `@tool` function, or in a workflow. See [Create an integration](/capabilities/build/agents/creating-an-integration).

### Pass them to the agent

```python title="src/research/__init__.py"
        reviewer = await ReviewerAgent.create_agent(
            self.engine, MODULE_ID, tools=[*tools, count_words]
        )
        self.expose_agent(ReviewerAgent.NAME, reviewer.as_handler())
```

Another module's agent goes in the same list: see [Add sub-agents](/capabilities/build/agents/add-sub-agents). Restart the module to publish the change.

## REST API

Not applicable. No HTTP call attaches a tool: the list is built in `on_initialized`.

## Config

Not applicable. `config.yaml` does not list an agent's tools.

## What the agent always has

Besides the tools you pass, every agent gets the default tool `get_time_date`; `enable_default_tools=False` on the agent leaves it out. Tool names keep letters, digits, `_` and `-`, and two tools with one name keep the first. The chat model has to support tool calling. See the key concepts on [Tools](/capabilities/build/tools/overview#key-concepts).
