---
question: How do I expose a workflow as agent tools?
kind: task
via_web: na
via_cli: na
via_python: available
via_api: na
via_config: na
ref_python: as_tools()
prereq: You need a workflow class in an in-engine module. [Create a workflow](/user-guide/build/agents/creating-a-workflow) first.
next:
  - /capabilities/build/agents/give-it-tools
  - /capabilities/build/workflows/test-a-workflow
  - /capabilities/build/agents/test-an-agent
---

# Expose as a tool

An agent calls a workflow through the LangChain tools that the workflow's `as_tools()` returns. `as_tools` is abstract on `Expose`, so every workflow implements it. `abi new workflow` already writes one tool that calls `run`: give it a name and a description the model can match, then hand the tools to an agent.

## Web UI

Not applicable. Nexus lists an agent's tools in Settings › Agents but cannot attach a workflow's tools: they are set in the agent's Python `New()`. Use the Python steps on this page.

## CLI

Not applicable. No command adds a tool. `abi new workflow` writes an `as_tools()` stub with the workflow; fill it in as in the Python steps.

## Python

### Return the tools

One `StructuredTool` per action. The `args_schema` is the parameters model, so its `Field(description=...)` texts tell the model how to fill each argument:

```python title="workflows/CustomersWorkflow.py"
from langchain_core.tools import BaseTool, StructuredTool


class CustomersWorkflow(Workflow[CustomersWorkflowParameters]):
    ...

    def as_tools(self) -> list[BaseTool]:
        return [
            StructuredTool(
                name="summarize_entity",
                description=(
                    "Summarize an entity from the knowledge graph. "
                    "Use when asked for information about an entity."
                ),
                func=lambda **kwargs: self.run(CustomersWorkflowParameters(**kwargs)),
                args_schema=CustomersWorkflowParameters,
            )
        ]
```

Tool names may hold letters, digits, `_` and `-`. The agent replaces any other character with `_`.

### Hand them to an agent

In the agent's `New()`, import the workflow and add its tools. Import inside `New()`: the engine treats every exposed class found in an `agents/` file as an agent.

```python title="agents/CustomersAgent.py"
tools: list = []

from my_module.workflows.CustomersWorkflow import (
    CustomersWorkflow,
    CustomersWorkflowConfiguration,
)

tools += CustomersWorkflow(CustomersWorkflowConfiguration()).as_tools()
```

The scaffolded `New()` lists the tools in the `[TOOLS]` block of the system prompt. The full method is on [Give it tools](/user-guide/build/agents/give-it-tools).

### Restart and try it

Restart the engine, then ask the agent for that intent in Nexus chat or with `abi chat my_module CustomersAgent`. See [Test an agent](/user-guide/build/agents/test-an-agent).

## REST API

Not applicable. A tool is agent-internal: the API gives a LangChain tool no route. To call the workflow over HTTP, see [Expose as an API](/user-guide/build/workflows/expose-as-an-api).

## Config

Not applicable. Which tools an agent has is set in its Python `New()`, not in `config.yaml`.
