mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-24 19:04:04 +08:00
* fix: nightly now properly gets 1.9.0 branch (#12215) before it was attempting to pull release-notes as letters are alphanumerically after numbers when we sort -V then grab tail now we only look at branch names that follow the pattern '^release-[0-9]+\.[0-9]+\.[0-9]+$' * docs: add search icon (#12216) add-back-svg * initial-content * cut-1.8-release-and-include-next-version * stage-1.8.0-and-next --------- Co-authored-by: Adam-Aghili <149833988+Adam-Aghili@users.noreply.github.com>
156 lines
9.2 KiB
Plaintext
156 lines
9.2 KiB
Plaintext
---
|
|
title: Use Langflow agents
|
|
slug: /agents
|
|
---
|
|
|
|
import Icon from "@site/src/components/icon";
|
|
import PartialParams from '@site/docs/_partial-hidden-params.mdx';
|
|
import PartialAgentsWork from '@site/docs/_partial-agents-work.mdx';
|
|
import PartialGlobalModelProviders from '@site/docs/_partial-global-model-providers.mdx';
|
|
|
|
Langflow's [**Agent** component](/components-agents) is critical for building agent flows.
|
|
This component provides everything you need to create an agent, including multiple Large Language Model (LLM) providers, tool calling, and custom instructions.
|
|
It simplifies agent configuration so you can focus on application development.
|
|
|
|
<PartialAgentsWork />
|
|
|
|
## Use the Agent component in a flow
|
|
|
|
The following steps explain how to create an agent flow in Langflow from a blank flow.
|
|
For a prebuilt example, use the **Simple Agent** template or the [Langflow quickstart](/get-started-quickstart).
|
|
|
|
1. Click **New Flow**, and then click **Blank Flow**.
|
|
2. Add an **Agent** component to your flow.
|
|
3. <PartialGlobalModelProviders />
|
|
4. Select the model that you want to use from the **Language Model** dropdown.
|
|
If your preferred model isn't listed, make sure it's enabled in the **Models** configuration.
|
|
For more information, see [Agent component parameters](#agent-component-parameters).
|
|
5. Add [**Chat Input** and **Chat Output** components](/chat-input-and-output) to your flow, and then connect them to the **Agent** component.
|
|
|
|
At this point, you have created a basic LLM-based chat flow that you can test in the <Icon name="Play" aria-hidden="true"/> **Playground**.
|
|
However, this flow only chats with the LLM.
|
|
To enhance this flow and make it truly agentic, add some tools, as explained in the next steps.
|
|
|
|

|
|
|
|
6. Add **Web Search**, **URL**, and **Calculator** components to your flow.
|
|
7. Enable **Tool Mode** in the **Web Search**, **URL**, and **Calculator** components:
|
|
|
|
1. Click the **Web Search** component to expose the [component's header menu](/concepts-components#component-menus), and then enable **Tool Mode**.
|
|
2. Repeat for the **URL** and **Calculator** components.
|
|
3. Connect the **Toolset** port for each tool component to the **Tools** port on the **Agent** component.
|
|
|
|
**Tool Mode** makes a component into a tool by modifying the component's inputs.
|
|
With **Tool Mode** enabled, a component can accept requests from an **Agent** component to use the component's available actions as tools.
|
|
|
|
When in **Tool Mode**, a component has a **Toolset** port that you must connect to an **Agent** component's **Tools** port if you want to allow the agent to use that component's actions as tools.
|
|
|
|
For more information, see [Configure tools for agents](/agents-tools).
|
|
|
|

|
|
|
|
8. Open the <Icon name="Play" aria-hidden="true"/> **Playground**, and then ask the agent, `What tools are you using to answer my questions?`
|
|
|
|
The agent should respond with a list of the connected tools.
|
|
It may also include built-in tools.
|
|
|
|
```text
|
|
I use a combination of my built-in knowledge (up to June 2024) and a set of external tools to answer your questions. Here are the main types of tools I can use:
|
|
Web Search & Content Fetching: I can fetch and summarize content from web pages, including crawling links recursively.
|
|
News Search: I can search for recent news articles using Google News via RSS feeds.
|
|
Calculator: I can perform arithmetic calculations and evaluate mathematical expressions.
|
|
Date & Time: I can provide the current date and time in various time zones.
|
|
These tools help me provide up-to-date information, perform calculations, and retrieve specific data from the internet when needed. If you have a specific question, let me know, and I'll use the most appropriate tool(s) to help!
|
|
```
|
|
|
|
9. To test a specific tool, ask the agent a question that uses one of the tools, such as `Summarize today's tech news`.
|
|
|
|
To help you debug and test your flows, the **Playground** displays the agent's tool calls, the provided input, and the raw output the agent received before generating the summary.
|
|
With the given example, the agent should call the **Web Search** component with **Search Mode** set to **News**.
|
|
|
|
You've successfully created a basic agent flow that uses some generic tools.
|
|
|
|
To continue building on this tutorial, try connecting other tool components or [use Langflow as an MCP client](/mcp-client) to support more complex and specialized tasks.
|
|
|
|
For a multi-agent example, see [Use an agent as a tool](/agents-tools#use-an-agent-as-a-tool).
|
|
|
|
## Agent component parameters
|
|
|
|
You can configure the **Agent** component to use your preferred provider and model, custom instructions, and tools.
|
|
|
|
<PartialParams />
|
|
|
|
### Provider and model
|
|
|
|
Use the **Language Model** (`agent_llm`) setting to select the LLM that you want the agent to use.
|
|
|
|
<PartialGlobalModelProviders />
|
|
|
|
To use a model with the **Agent** component, select the model in the **Agent** component's **Language Model** field.
|
|
|
|
The **Language Model** field lists all language models that you've configured globally. If a provider doesn't have any language models available, they aren't listed.
|
|
For example, if a provider offers only embeddings models, those models aren't listed on the **Agent** component.
|
|
|
|
To access other providers or models, you can do either of the following:
|
|
|
|
* Connect any [language model component](/components-models) to the **Agent** component's **Language Model** port. This option allows you to connect a custom language model component to use models that aren't available in the global model providers list.
|
|
* Configure additional providers in the **Models** pane, and then select the model from the **Language Model** dropdown.
|
|
|
|
If you need to generate embeddings in your flow, use an [embedding model component](/components-embedding-models).
|
|
|
|
### Agent instructions and input
|
|
|
|
In the **Agent Instructions** (`system_prompt`) field, you can provide custom instructions that you want the **Agent** component to use for every conversation.
|
|
|
|
These instructions are applied in addition to the **Input** (`input_value`), which can be entered directly or provided through another component, such as a **Chat Input** component.
|
|
|
|
### Tools
|
|
|
|
Agents are most useful when they have the appropriate tools available to complete requests.
|
|
|
|
An **Agent** component can use any Langflow component as a tool, including other agents and MCP servers.
|
|
|
|
To attach a component as a tool, you must enable **Tool Mode** on the component that you want to attach, and then attach it to the **Agent** component's **Tools** port.
|
|
For more information, see [Configure tools for agents](/agents-tools).
|
|
|
|
:::tip
|
|
To allow agents to use tools from MCP servers, use the [**MCP Tools** component](/mcp-tools).
|
|
:::
|
|
|
|
### Agent memory
|
|
|
|
Langflow agents have built-in chat memory that is enabled by default.
|
|
This memory allows them to retrieve and reference messages from previous conversations, maintaining a rolling context window for each chat session ID.
|
|
|
|
Chat memories are grouped by [session ID (`session_id`)](/session-id).
|
|
It is recommended to use custom session IDs if you need to segregate chat memory for different users or applications that run the same flow.
|
|
|
|
By default, the **Agent** component uses your Langflow installation's storage, and it retrieves a limited number of chat messages, which you can configure with the **Number of Chat History Messages** parameter.
|
|
|
|
The **Message History** component isn't required for default chat memory, but it is required if you want to use external chat memory like Mem0.
|
|
Additionally, the **Message History** component provides more options for sorting, filtering, and limiting memories. Although, most of these options are built-in to the **Agent** component with default values.
|
|
|
|
For more information, see [Store chat memory](/memory#store-chat-memory) and [**Message History** component](/message-history).
|
|
|
|
### Additional parameters
|
|
|
|
With the **Agent** component, the available parameters can change depending on the selected provider and model, including support for additional modes, arguments, or features like chat memory and temperature.
|
|
For example:
|
|
|
|
* **Current Date** (`add_current_date_tool`): When enabled (`true`), this setting adds a tool to the agent that can retrieve the current date.
|
|
* **Handle Parse Errors** (`handle_parsing_errors`): When enabled (`true`), this setting allows the agent to fix errors, like typos, when analyzing user input.
|
|
* **Verbose** (`verbose`): When enabled (`true`), this setting records detailed logging output for debugging and analysis.
|
|
|
|
<PartialParams />
|
|
|
|
## Agent component output
|
|
|
|
The **Agent** component outputs a **Response** (`response`) that is [`Message` data](/data-types#message) containing the agent's raw response to the query.
|
|
|
|
Typically, this is passed to a **Chat Output** component to return the response in a human-readable format.
|
|
It can also be passed to other components if you need to process the response further before, or in addition to, returning it to the user.
|
|
|
|
## See also
|
|
|
|
* [**Agent** and **MCP Tools** components](/components-agents)
|
|
* [Configure tools for agents](/agents-tools) |