Langchain tools and agents. AgentExecutor # class langchain.


Langchain tools and agents. May 28, 2025 · Agents are the most powerful abstraction in LangChain. Sep 25, 2023 · While each agent in LangChain is designed for specific tasks, custom tools empower users to fully customize and control the tool’s actions, data handling, and execution. May 9, 2025 · Conclusion LangChain provides a robust framework for building AI agents that combine the reasoning capabilities of LLMs with the functional capabilities of specialized tools. LangChain is great for building such interfaces because it has: Good model output parsing, which makes it easy to extract JSON, XML, OpenAI function-calls, etc. Class hierarchy: Final response: Evaluate the agent's final response. Besides the actual function that is called, the Tool consists of several components: name (str), is required and must be unique within a set of tools provided to an agent description (str), is optional but recommended, as it is used by an agent to determine tool use args Jul 9, 2023 · With Langchain’s Agent Tools, developers can employ a specialized agent that executes a tool specifically designed for the login logic. Class hierarchy: ToolMetaclass --> BaseTool --> <name>Tool # Examples: AIPluginTool, BaseGraphQLTool <name> # Examples: BraveSearch, HumanInputRun Main helpers: Agents 🤖 Agents are like "tools" for LLMs. That's where Agents come in! LangChain comes with a number of built-in agents that are optimized for different use A big use case for LangChain is creating agents. (By bind -ing the functions, we Dec 12, 2024 · Build LangChain agents step by step to create AI assistants that automate tasks and integrate advanced tools seamlessly. Mar 17, 2025 · In conclusion, LangChain’s tools and agents represent a significant leap forward in the development of AI applications. We hope to continue developing different toolkits that can enable agents to do amazing feats. Contents What are Agents? Building the Agent - The Tools - The Oct 29, 2024 · A. Jan 3, 2025 · An agent in Langchain is a dynamic system that can make decisions based on a given task, interact with external resources (referred to as tools), and perform multiple steps to complete a task. note Sep 18, 2024 · Best Practices for Using Langchain Agents Tool Selection: Choose the right tools for your agent based on the task at hand. Jan 3, 2025 · LangChain agents are a pivotal component of the LangChain framework. Jul 23, 2025 · LangChain is an open-source framework designed to simplify the creation of applications using large language models (LLMs). Mar 1, 2023 · Today, we're announcing agent toolkits, a new abstraction that allows developers to create agents designed for a particular use-case (for example, interacting with a relational database or interacting with an OpenAPI spec). In this example, we will use OpenAI Tool Calling to create this agent. This is usually powered by a language model, a prompt, and an output parser. LangChain comes with a number of built-in agents that are optimized for different use cases. Note that this requires an API key - they have a free tier, but if you don’t have one or don’t want to create one, you can always ignore While other tools (like the Requests tools) are fine for static sites, PlayWright Browser toolkits let your agent navigate the web and interact with dynamically rendered sites. 📄️ ArXiv This notebook goes over how to use the arxiv tool with an agent. Setup Jul 4, 2025 · Discover 7 essential steps to building multi-AI agent workflows with LangChain—plus real examples, key benefits, and best practices from Intuz. 1. For a list of toolkit integrations, see this page. Feb 13, 2024 · Plan and execute agents promise faster, cheaper, and more performant task execution over previous agent designs. A toolkit is a collection of tools meant to be used together. May 2, 2023 · TL;DR: we're introducing a new abstraction to allow for usage of more complex tools. Nov 30, 2023 · LangChain Agents are systems that use an LM to interact with other tools for tasks such as grounded questions-answering or API interaction agents # Agent is a class that uses an LLM to choose a sequence of actions to take. This is generally the most reliable way to create agents. AgentExecutor # class langchain. If you're creating agents using OpenAI models, you should be using this OpenAI Tools agent rather than the OpenAI functions agent. We will use two tools: Tavily (to search online) and then a retriever over a local index we will create Tavily We have a built-in tool in LangChain to easily use Tavily search engine as tool. LangChain is a framework designed for building applications that integrate Large Language Models (LLMs) with various external tools and APIs, enabling developers to create intelligent agents capable of performing complex tasks. Using LangChain Tools ADK provides the LangchainTool wrapper to integrate tools from the LangChain ecosystem into Mar 1, 2025 · Learn how LangGraph, an AI agent framework built by LangChain, allows developers to create complex and flexible agent workflows using stateful graphs and built-in memory management. Read about all the agent types here. In this tutorial we Tool use and agents An exciting use case for LLMs is building natural language interfaces for other "tools", whether those are APIs, functions, databases, etc. How to: pass in callbacks at runtime How to: attach callbacks to a module How to: pass callbacks into a module constructor How to: create custom callback handlers How to: use callbacks in For a quick start to working with agents, please check out this getting started guide. When the agent reaches a stopping condition, it returns a final return value. Intermediate agent actions and tool output messages will be passed in here. Apr 11, 2024 · LangChain already has a create_openai_tools_agent() constructor that makes it easy to build an agent with tool-calling models that adhere to the OpenAI tool-calling API, but this won’t work for models like Anthropic and Gemini. We recommend that you use LangGraph for building agents. It can recover from errors by running a generated query Learn to build AI agents with LangChain and LangGraph. Agent We'll use an OpenAI chat model and an "openai-tools" agent, which will use OpenAI's function-calling API to drive the agent's tool selection and invocations. Next, we will use the high level constructor for this type of agent. Trajectory: Evaluate whether the agent took the expected path (e. This will assume knowledge of LLMs and retrieval so if you haven't already explored those sections, it is recommended you do so. By leveraging Langchain’s Agent Tools, developers gain the flexibility and efficiency to dynamically execute functions and APIs based on user requirements. , whether it selects the appropriate first tool for a given step). This chapter will explore how to build custom tools for agents in LangChain. Create autonomous workflows using memory, tools, and LLM orchestration. Join us August 19 in San Francisco for LangChain Academy Live — a hands-on workshop to master building reliable agents. AgentExecutor [source] # Bases: Chain Agent that is using tools. In Apr 25, 2024 · In this post, we will delve into LangChain’s capabilities for Tool Calling and the Tool Calling Agent, showcasing their functionality through examples utilizing Anthropic’s Claude 3 model. The toolkit provides access to Polygon's Stock Market Data API. tools # Tools are classes that an Agent uses to interact with the world. They combine a few things: The name of the tool A description of what the tool is JSON schema of what the inputs to the tool are The function to call Whether the result of a tool should be returned directly to the user It is useful to have all this information because this information can be used to Jun 17, 2025 · Build an Agent LangChain supports the creation of agents, or systems that use LLMs as reasoning engines to determine which actions to take and the inputs necessary to perform the action. Use LCEL, which simplifies the customization of chains and agents, to build applications; Apply function calling to tasks like tagging and data extraction; Understand tool selection and routing using LangChain tools and LLM function calling – and much more. Tools can be just about anything — APIs, functions, databases, etc. Apr 9, 2025 · Learn how to make REST API calls in LangChain agents using custom tools, Python, and best practices for real-world integration. Learn to build smarter, adaptive systems today. Agents are used when a single input/output process is not enough, and the task requires reasoning, planning, or interaction with external systems. It uses LangChain’s ToolCall interface to support a wider range of provider implementations, such as Anthropic, Google Gemini, and Mistral in addition to OpenAI. In chains, a sequence of actions is hardcoded (in code). Ensure that the LLM understands when and how to invoke these tools. One of its most exciting aspects is the Agents May 30, 2023 · If you’ve just started looking into LangChain and wonder how you could use agents as tools for other agents, you’ve come to the right place. To improve your LLM application development, pair LangChain with: LangSmith - Helpful for agent evals and observability. Agents LangChain offers a number of tools and functions that allow you to create SQL Agents which can provide a more flexible way of interacting with SQL databases. Each tool has a description. How to use tools in a chain In this guide, we will go over the basic ways to create Chains and Agents that call Tools. A large collection of built-in Tools. Besides the actual function that is called, the Tool consists of several components: If you're using pre-built LangChain or LangGraph components like create_react_agent,you might not need to interact with tools directly. Whereas a chain defines an immediate input/output process, the logic of agents allows a step-by-step thought process. agents. The agent returns the observation to the LLM, which can then be used to generate the next action. Nov 22, 2024 · LangChain is a powerful framework designed to build AI-powered applications by connecting language models with various tools, APIs, and data sources. Aug 28, 2024 · A comprehensive tutorial on building multi-tool LangChain agents to automate tasks in Python using LLMs and chat models using OpenAI. Tools are essentially functions that extend the agent’s capabilities by Apr 10, 2024 · Photo by Dan LeFebvre on Unsplash Let’s build a simple agent in LangChain to help us understand some of the foundational concepts and building blocks for how agents work there. For this, only basic LangChain features were required, namely model loading, prompt management, and invoking the model with rendered prompt. Jan 3, 2025 · The agent autonomously manages this sequence, ensuring smooth and intelligent task execution. from model outputs. The schemas for the agents themselves are defined in langchain. Memory modules: Let agents remember past interactions. From tools to agent loops—this guide covers it all with real code, best practices, and advanced tips. Concepts Concepts we will cover are: Using language models, in particular their tool calling ability Sep 9, 2024 · Agents: A higher order abstraction that uses an LLMs reasoning capabilities for structuring a complex query into several distinct tasks. May 2, 2023 · LangChain is a framework for developing applications powered by language models. , runs the tool), and receives an observation. Third Party Tools ADK is designed to be highly extensible, allowing you to seamlessly integrate tools from other AI Agent frameworks like CrewAI and LangChain. 📄️ Apify This notebook shows how to use the Apify integration for LangChain. By understanding the core architecture — LLMs, tools, chains, memory, and the agent loop — developers can create sophisticated agents tailored to specific use cases. Custom agent This notebook goes through how to create your own custom agent. Many agents will only work with tools that have a single string input. Jun 4, 2025 · A Langchain agent is an LLM-based decision-maker that receives user prompts, thinks step-by-step (usually using ReAct or similar frameworks), chooses what action to take, and executes it using a set of available tools. Define tools We first need to create the tools we want to use. g. You will be able to ask this agent questions, watch it call tools, and have conversations with it. This example illustrates how agents in LangChain transform simple tasks into intelligent workflows. Includes support for in-memory and Postgres backends. . This is often achieved via tool-calling. After taking this course, you’ll know how to: - Generate structured output, including function calls, using LLMs; - Use LCEL, which simplifies the customization of chains and agents, to build applications; - Apply function calling to tasks like tagging and data extraction; - Understand tool selection and routing using LangChain tools and LLM The agent executes the action (e. Nov 6, 2024 · LangChain is revolutionizing how we build AI applications by providing a powerful framework for creating agents that can think, reason, and take actions. In Chains, a sequence of actions is hardcoded. You have to define a function and Apr 13, 2023 · Langchain Agents, powered by advanced Language Models (LLMs), are transforming the way we interact with data, perform searches, and execute tasks. Jun 2, 2024 · LangChain offers a robust framework for working with agents, including: - A standard interface for agents. This is just one of the many uses of LangChain, which offers a whole arsenal of tools to take your generative AI projects to the next level. Actions can include: Calling tools (APIs, functions, databases 🧰 Scalable access to tools: Equip agents with hundreds or thousands of tools. Their framework enables you to build layered LLM-powered applications that are context-aware and able to interact dynamically with their environment as agents, leading to simplified code for you and a more dynamic user experience for your customers. Here we focus on how to move from legacy LangChain agents to more flexible LangGraph agents. Agents select and use Tools and Toolkits for actions. The main advantages of using SQL Agents are: It can answer questions based on the databases schema as well as on the databases content (like describing a specific table). The results of those actions can then be fed back into the agent and it determine whether more actions are needed, or whether it is okay to finish. They allow a LLM to access Google search, perform complex calculations with Python, and even make SQL queries. 💻 Welcome to the "Functions, Tools and Agents with LangChain" course! Instructed by Harrison Chase, Co-Founder and CEO at LangChain, this course will keep you updated with the latest advancements in Large Language Models (LLMs) and the libraries supporting them. In Agents, a language model is used as a reasoning engine to determine which actions to take and in which order. , of tool calls) to arrive at the final answer. In the OpenAI Chat API, functions are now considered a legacy options that is deprecated in favor of tools. Self-ask Tools for every task LangChain offers an extensive library of off-the-shelf tools u2028and an intuitive framework for customizing your own. This interoperability is crucial because it allows for faster development time and allows you to reuse existing tools. In this notebook we will show how those parameters map to the LangGraph react agent executor using the create_react_agent prebuilt helper method. As we can see, the agent will first choose which tables are relevant and then add the schema for those tables and a few sample rows to the prompt. Defining Custom Tools When constructing your own agent, you will need to provide it with a list of Tools that it can use. In this notebook we'll explore agents and how to use them in LangChain. Start applying these new capabilities to build and improve your applications today. Aug 25, 2024 · In LangChain, an “Agent” is an AI entity that interacts with various “Tools” to perform tasks or answer queries. Using tools allows the model to request that more than one function will be called upon when appropriate. Tools allow us to extend the capabilities of a model beyond just outputting text/messages. To pass in our tools to the agent, we just need to format them to the OpenAI function format and pass them to our model. That means there are two main considerations when thinking about different multi-agent workflows: What are the multiple independent agents? How are those agents connected? This thinking lends itself incredibly well to a graph representation, such as that provided by langgraph. Agents Agents can be thought of as the chain responsible for deciding what step to take next. Apr 24, 2024 · In this tutorial, we will build an agent that can interact with multiple different tools: one being a local database, the other being a search engine. Deploy and scale with LangGraph Platform, with APIs for state management, a visual studio for debugging, and multiple deployment options. Concepts There are several key concepts to understand when building agents: Agents, AgentExecutor, Tools, Toolkits. This covers basics like initializing an agent, creating tools, and adding memory. In agents, a language model is used as a reasoning engine to determine which actions to take and in which order. By autonomously making decisions and invoking tools, agents enhance automation, reduce human intervention, and deliver scalable solutions Bind tools to LLM How does the agent know what tools it can use? In this case we're relying on OpenAI function calling LLMs, which take functions as a separate argument and have been specifically trained to know when to invoke those functions. We are also introducing a new agent class that works well with these How to create tools When constructing an agent, you will need to provide it with a list of Tools that it can use. For an in depth explanation, please check out this conceptual Chains refer to sequences of calls - whether to an LLM, a tool, or a data preprocessing step. Build controllable agents with LangGraph, our low-level agent orchestration framework. Finally, we will walk through how to construct a conversational retrieval agent from components. Why do LLMs need to use Tools? Toolkits are collections of tools that are designed to be used together for specific tasks. Learn how to build LangChain agents in Python. They enable LLMs to choose actions, call tools, and perform reasoning steps dynamically — like autonomous copilots for your applications. In some situations, this can help signficantly This section will cover how to create conversational agents: chatbots that can interact with other systems and APIs using tools. 📝 Storage of tool metadata: Control storage of tool descriptions, namespaces, and other information through LangGraph's built-in persistence layer. Classes Apr 4, 2025 · LangChain Agent Framework enables developers to create intelligent systems with language models, tools for external interactions, and more. To start, we will set up the retriever we want to use, and then turn it into a retriever tool. Jun 26, 2025 · Discover how LangChain agents are transforming AI with advanced tools, APIs, and workflows. The tool decorator is an easy way to create tools. LangChain allows AI developers to develop applications based on the combined Large Language Models (such as GPT-4) with external sources of Jan 23, 2024 · Each agent can have its own prompt, LLM, tools, and other custom code to best collaborate with the other agents. Feb 16, 2025 · This article explores LangChain’s Tools and Agents, how they work, and how you can leverage them to build intelligent AI-powered applications. They have convenient loading methods. 📄️ AWS Lambda Amazon AWS Lambda is a Apr 11, 2024 · Quickstart To best understand the agent framework, let's build an agent that has two tools: one to look things up online, and one to look up specific data that we've loaded into a index. Oct 24, 2024 · How to build Custom Tools in LangChain 1: Using @tool decorator: There are several ways to build custom tools. Using agents This is an agent specifically optimized for doing retrieval when necessary and also holding a conversation. What Are LangChain Tools? How to: use legacy LangChain Agents (AgentExecutor) How to: migrate from legacy LangChain agents to LangGraph Callbacks Callbacks allow you to hook into the various stages of your LLM application's execution. Memory is needed to enable conversation. They enable large language models (LLMs) to interact with external tools and systems, extending their capabilities beyond Concepts The core idea of agents is to use a language model to choose a sequence of actions to take. This guide provides explanations of the key concepts behind the LangChain framework and AI applications more broadly. Understand how LangChain agents enhance LLM applications by dynamically integrating external tools, APIs, and real-time data access. May 4, 2025 · Tool integrations: Connect LLMs to APIs, search engines, databases, and more. In these cases, we want to let the model itself decide how many times to use tools and in what order. This article quickly goes over the basics of agents Tools are utilities designed to be called by a model: their inputs are designed to be generated by models, and their outputs are designed to be passed back to models. Toolkits are supported May 24, 2024 · Discover how LangChain empowers developers to create sophisticated AI agents by integrating with 10 powerful tools, from financial data analysis and image generation to SEO optimization and biomedical research. By combining robust building blocks with intelligent orchestrators, LangChain empowers developers to create dynamic, context-aware, and scalable solutions that can transform industries and enhance user experiences. This is a more generalized version of the OpenAI tools agent, which was designed for OpenAI’s specific style of tool calling. Different agents have different prompting styles for reasoning, different ways Tools for every step of the agent development lifecycle -- built to unlock powerful AI in production. An introduction to Open Agent PlatformOpen Agent Platform is a citizen developer platform, allowing non-technical users to build, prototype, and use agents. Agent uses the description to choose the right tool for the job. But for certain use cases, how many times we use tools depends on the input. By keeping it simple we can get a better grasp of the foundational ideas behind these agents, allowing us to build more complex agents in the future. Single step: Evaluate any agent step in isolation (e. After executing actions, the results can be fed back into the LLM to determine whether more actions are needed, or whether it is okay to finish. Load the LLM First, let's load the language model we're going to Jun 17, 2025 · Build a smart agent with LangChain that allows LLMs to look for the latest trends, search the web, and summarize results using real-time tool calling. 📄️ Polygon IO Toolkit This notebook shows how to use agents to interact with the Polygon IO toolkit. In an earlier article, I investigated LangChain in the context of solving classical NLP tasks. These agents can be connected to a wide range of tools, RAG servers, and even other agents through an Agent Supervisor! For a quick start to working with agents, please check out this getting started guide. We'll use the tool calling agent, which is generally the most reliable kind and the recommended one for most use cases. The agent prompt must have an agent_scratchpad key that is a MessagesPlaceholder. Tools 📄️ Alpha Vantage Alpha Vantage Alpha Vantage provides realtime and historical financial market data through a set of powerful and developer-friendly data APIs and spreadsheets. Setup: LangSmith By definition, agents take a self-determined, input-dependent Tools and Toolkits Tools are utilities designed to be called by a model: their inputs are designed to be generated by models, and their outputs are designed to be passed back to models. The key to using models with tools is correctly prompting a model and parsing its response so that it chooses the Tools Tools are interfaces that an agent, chain, or LLM can use to interact with the world. Agents are systems that take a high-level task and use an LLM as a reasoning engine to decide what actions to take and execute those actions. We will first create it WITHOUT memory, but we will then show how to add memory in. The simpler the input to a tool is, the easier it is for an LLM to be able to use it. For an in depth explanation, please check out this conceptual Tool calling agent Tool calling allows a model to detect when one or more tools should be called and respond with the inputs that should be passed to those tools. It provides a standard interface for chains, many integrations with other tools, and end-to-end chains for common applications. - A variety of pre-built agents to choose from. Learn how to build 3 types of planning agents in LangGraph in this post. agents # Agent is a class that uses an LLM to choose a sequence of actions to take. We’ll start with a couple of simple tools to help us understand the typical tool building pattern before moving on to more complex tools using other ML models to give us even more abilities like describing images. For a list of agent types and which ones work with more complicated inputs, please see this documentation Importantly, the name, description, and schema (if used) are all used in the prompt. LangChain can parse LLM output to identify tasks, and then query an LLM repetitively until all tasks are completed, thereby synthesizing intermediate results into a final answer. Dec 26, 2024 · Create a powerful Web-Searching Agent with LangChain for efficient, scalable data retrieval using multiple tools and APIs. agent. Provides a lot of Agents let us do just this. The primary supported way to do this is with LCEL. Class hierarchy: Jun 19, 2025 · Build AI agents from scratch with LangChain and OpenAI. Agent modules: Create autonomous systems that decide which tool to use and when. We'll start by installing the prerequisite libraries that we'll be using in this example. LangChain makes it significantly easier to build AI agents that are not only smart but also actionable and contextual. While previous tools took in a single string input, new tools can take in an arbitrary number of inputs of arbitrary types. LangGraph is an extension of LangChain specifically aimed at creating highly controllable and customizable agents. By leveraging the power of these agents, users Agents are systems that take a high-level task and use an LLM as a reasoning engine to decide what actions to take and execute those actions. In this tutorial, we will explore how to build a multi-tool agent using LangGraph within the LangChain framework to get a better… Agents Chains are great when we know the specific sequence of tool usage needed for any user input. However, understanding how to use them can be valuable for debugging and testing. Agents are systems that use an LLM as a reasoning engine to determine which actions to take and what the inputs to those actions should be. In an API call, you can describe tools and have the model intelligently choose to output a structured object like JSON containing arguments to call these tools. This library is These tools and the thought process separate agents from chains in LangChain. LangChain agents (the AgentExecutor in particular) have multiple configuration parameters. In this comprehensive guide, we’ll LangChain’s ecosystem While the LangChain framework can be used standalone, it also integrates seamlessly with any LangChain product, giving developers a full suite of tools when building LLM applications. There are several key components here: Schema LangChain has several abstractions to make working with agents easy Sep 9, 2024 · A remarkable library for using LLMs is LangChain. LangChain is the tool that you and your team might use to develop automated systems that review and moderate user-generated content by identifying and filtering inappropriate or harmful material. 💡 Customization of tool retrieval: Optionally define custom functions for tool retrieval. 🤖 What Is an Agent in LangChain? An Agent uses an LLM to decide what action to take based on the input and intermediate results. pnose lykeer quxgs ygedtzl vojru ekhr tlvfemb cvoqs alvl pvgpj