Understanding LangChain Agent Types — From ReAct to Function Calling
LangChain agents are the decision-making layer of an AI application. They determine which tools to call, in what order, and how to process the results. Over the past year, LangChain has expanded and refined the types of agents it supports, making it easier to match the right architecture to your specific use case.
What Does an Agent Do?
An agent in LangChain is responsible for:
- Understanding the user request — Processing and interpreting the input
- Reasoning about the best way to solve it — Planning the approach
- Acting by calling tools, APIs, or databases — Executing the plan
- Iterating if necessary — Refining results until a goal is met
Some agents operate in multi-step loops (reason → act → observe → repeat), while others make a single structured function call.
Main Agent Types in LangChain
1. ReAct Agents (Reason + Act)
The ReAct pattern is one of the earliest and most flexible agent styles in LangChain. It mixes internal reasoning ("Thought:") with external actions ("Action:") in an iterative loop.
🔄 ReAct Workflow Example
- Thought: "I need the latest sales data."
- Action: Call SQL tool.
- Observation: Received table.
- Thought: "Now calculate the total revenue."
- Action: Call calculator tool.
Key APIs:
create_react_agent
(current)- Legacy:
ZERO_SHOT_REACT_DESCRIPTION
,CONVERSATIONAL_REACT_DESCRIPTION
Best suited for: Multi-step reasoning, flexible tool usage, and adaptive workflows.
2. Function-Calling (Tool Calling) Agents
Function-calling agents produce structured tool calls instead of free-form reasoning. Rather than describing what to do in plain text, the LLM outputs JSON-like arguments for a predefined function.
Key APIs:
create_tool_calling_agent
create_openai_functions_agent
Best suited for: Predictable, API-like interactions where output structure must be preserved.
3. Plan-and-Execute Agents
These agents separate the planning and execution phases:
- The Planner LLM decides on a complete step-by-step plan.
- The Executor LLM runs each step in order.
Best suited for: Complex tasks that require a clear plan before execution.
4. Multi-Action and Structured Agents
These are advanced agent types:
- Multi-action agents can call several tools in a single step.
- Structured agents follow strict schemas for tool outputs.
Best suited for: High-performance applications and parallel tool execution.
Comparison Table
Agent Type | How It Works | Best For |
---|---|---|
ReAct | Thought → Action → Observation loops | Flexible, multi-step reasoning |
Function-Calling | One-shot, structured tool invocation | API integrations, predictable execution |
Plan-and-Execute | Plans steps first, then executes | Large, multi-step workflows |
Multi-Action / Structured | Multiple calls per step or schema-based | Performance and control in advanced systems |
Choosing the Right Agent
🎯 Decision Framework
- For creativity and adaptability → choose ReAct
- For strict output formats → use Function-Calling
- For long, complex workflows → choose Plan-and-Execute
- For speed and parallelism → try Multi-Action
Implementation Examples
ReAct Agent Example
from langchain.agents import create_react_agent
from langchain_openai import ChatOpenAI
from langchain import hub
# Get the prompt template
prompt = hub.pull("hwchase17/react")
# Create the agent
llm = ChatOpenAI(temperature=0)
agent = create_react_agent(llm, tools, prompt)
# Use with AgentExecutor
agent_executor = AgentExecutor(
agent=agent,
tools=tools,
verbose=True,
handle_parsing_errors=True
)
Function-Calling Agent Example
from langchain.agents import create_tool_calling_agent
from langchain_openai import ChatOpenAI
# Create the agent with structured tool calling
llm = ChatOpenAI(model="gpt-3.5-turbo-1106", temperature=0)
agent = create_tool_calling_agent(llm, tools, prompt)
# Execute with structured outputs
agent_executor = AgentExecutor(
agent=agent,
tools=tools,
verbose=True
)
Performance Considerations
ReAct Agents
- Pros: Very flexible, handles complex reasoning well
- Cons: Can be slower due to multiple LLM calls, may loop unnecessarily
Function-Calling Agents
- Pros: Fast, predictable output format, works well with OpenAI models
- Cons: Less flexible, limited reasoning capability
Plan-and-Execute Agents
- Pros: Great for complex workflows, clear execution path
- Cons: Can be rigid, doesn't adapt well to changing conditions
References
- LangChain: What is an Agent?
- Understanding ReAct vs Function-Calling Agents
- Context Engineering for Agents
💡 Key Takeaway: The right agent type depends on your specific use case. Start with Function-Calling for simple, structured tasks, use ReAct for complex reasoning, and consider Plan-and-Execute for large workflows. Multi-Action agents are perfect when you need maximum performance and control.
Building LangChain agents for production? Let's discuss how to choose and implement the right agent architecture for your use case.
💬 Share Your Thoughts
Have insights to share or questions about this post? I'd love to hear from you!