Skip to main content

Configure tools for agents

Configure tools connected to agents to extend their capabilities.

Edit a tool component's actions

To edit a tool's actions, in the tool component, click Edit Tools to modify its name, description, or enabled metadata. These fields help connected agents understand how to use the action, without having to modify the agent's prompt instructions.

For example, the URL component has two actions available when Tool Mode is enabled:

Tool NameDescriptionEnabled
fetch_contentFetch content from web pages recursivelytrue
fetch_content_as_messageFetch web content formatted as messagestrue

A Langflow Agent has a clear idea of each tool's capabilities based on the name and description metadata. The enabled boolean controls the tool's availability to the agent. If you think an agent is using a tool incorrectly, edit a tool's description metadata to help the agent better understand the tool.

Tool names and descriptions can be edited, but the default tool identifiers cannot be changed. If you want to change the tool identifier, create a custom component.

Use an agent as a tool

The agent component itself also supports Tool Mode for creating multi-agent flows.

Add an agent to your flow that uses a different OpenAI model for a larger context window.

  1. Create the Simple agent starter flow.
  2. Add a second agent component to the flow.
  3. Add your Open AI API Key to the Agent component.
  4. In the Model Name field, select gpt-4.1.
  5. Click Tool Mode to use this new agent as a tool.
  6. Connect the new agent's Toolset port to the previously created agent's Tools port. The new agent will use gpt-4.1 for the larger tasks of scraping and searching information that require large context windows. The previously created agent will now use this agent as a tool, with its unique LLM and toolset.

Agent as a tool

  1. The new agent's actions can be edited to help the agent understand how to use it. Click Edit Tools to modify its name, description, or enabled metadata. For example, the default tool name is Agent. Edit the name to Agent-gpt-41, and edit the description to Use the gpt-4.1 model for complex problem solving. The connected agent will understand that this is the gpt-4.1 agent, and will use it for tasks requiring a larger context window.

Add custom components as tools

An agent can use custom components as tools.

  1. To add a custom component to the agent flow, click New Custom Component.

  2. Add custom Python code to the custom component. For example, to create a text analyzer component, paste the below code into the custom component's Code pane.

Python

_50
from langflow.custom import Component
_50
from langflow.io import MessageTextInput, Output
_50
from langflow.schema import Data
_50
import re
_50
_50
class TextAnalyzerComponent(Component):
_50
display_name = "Text Analyzer"
_50
description = "Analyzes and transforms input text."
_50
documentation: str = "http://docs.langflow.org/components/custom"
_50
icon = "chart-bar"
_50
name = "TextAnalyzerComponent"
_50
_50
inputs = [
_50
MessageTextInput(
_50
name="input_text",
_50
display_name="Input Text",
_50
info="Enter text to analyze",
_50
value="Hello, World!",
_50
tool_mode=True,
_50
),
_50
]
_50
_50
outputs = [
_50
Output(display_name="Analysis Result", name="output", method="analyze_text"),
_50
]
_50
_50
def analyze_text(self) -> Data:
_50
text = self.input_text
_50
_50
# Perform text analysis
_50
word_count = len(text.split())
_50
char_count = len(text)
_50
sentence_count = len(re.findall(r'\w+[.!?]', text))
_50
_50
# Transform text
_50
reversed_text = text[::-1]
_50
uppercase_text = text.upper()
_50
_50
analysis_result = {
_50
"original_text": text,
_50
"word_count": word_count,
_50
"character_count": char_count,
_50
"sentence_count": sentence_count,
_50
"reversed_text": reversed_text,
_50
"uppercase_text": uppercase_text
_50
}
_50
_50
data = Data(value=analysis_result)
_50
self.status = data
_50
return data

  1. To use the custom component as a tool, click Tool Mode.
  2. Connect the custom component's tool output to the agent's tools input.
  3. Open the Playground and instruct the agent, Use the text analyzer on this text: "Agents really are thinking machines!"
Response

_11
AI
_11
gpt-4o
_11
Finished
_11
0.6s
_11
Here is the analysis of the text "Agents really are thinking machines!":
_11
Original Text: Agents really are thinking machines!
_11
Word Count: 5
_11
Character Count: 36
_11
Sentence Count: 1
_11
Reversed Text: !senihcam gnikniht era yllaer stnegA
_11
Uppercase Text: AGENTS REALLY ARE THINKING MACHINES!

The agent correctly calls the analyze_text action and returns the result to the Playground.

Make any component a tool

If the component you want to use as a tool doesn't have a Tool Mode button, add tool_mode=True to one of the component's inputs, and connect the new Toolset output to the agent's Tools input.

Langflow supports Tool Mode for the following data types:

  • DataInput
  • DataFrameInput
  • PromptInput
  • MessageTextInput
  • MultilineInput
  • DropdownInput

For example, the components as tools example above adds tool_mode=True to the MessageTextInput input so the custom component can be used as a tool.


_10
inputs = [
_10
MessageTextInput(
_10
name="input_text",
_10
display_name="Input Text",
_10
info="Enter text to analyze",
_10
value="Hello, World!",
_10
tool_mode=True,
_10
),
_10
]

Use flows as tools

An agent can use flows that are saved in your workspace as tools with the Run flow component.

  1. To add a Run flow component, click and drag a Run flow component to your workspace.
  2. Select the flow you want the agent to use as a tool.
  3. Enable Tool Mode in the component. The Run flow component displays your flow as an available action.
  4. Connect the Run flow component's tool output to the agent's tools input.
  5. Ask the agent, What tools are you using to answer my questions? Your flow should be visible in the response as a tool.
  6. Ask the agent to specifically use the connected tool to answer your question. The connected flow returns an answer based on your question. For example, a Basic Prompting flow connected as a tool returns a different result depending upon its LLM and prompt instructions.

Run Flow as tool connected to agnet

Search