StudyVisuallyStart studying
Part 06 · LangChain / LangGraph · Card 11 of 14

createReactAgent

A prebuilt ReAct agent: give it a model and tools, and it runs the loop for you.

Last updated

Analogy

create-next-app for agents. Fast start, and you can eject to a custom graph later.

Code example

react-agent.tsTypeScript
import { createReactAgent } from "@langchain/langgraph/prebuilt";
const agent = createReactAgent({ llm: model, tools: [searchDocs, listOpenPRs] });
const result = await agent.invoke({
messages: [{ role: "user", content: "How do we roll back a deploy?" }],
});

In an agent

It's the Part 4 loop, prewritten. You already know what it does inside.

Practice

Flashcards

  • What is ReAct?Reason, act (call a tool), observe the result, repeat.

Questions people ask

What does createReactAgent do in LangGraph?

It builds a ready-made ReAct agent from a model and a list of tools. It runs the familiar loop for you: call the model, run any tools it asks for, add the results, and repeat until it answers in text. It is the fastest way to get a working agent in LangGraph.

When should I move from createReactAgent to a custom graph?

When you need more than one loop: a router in front, approvals before write tools, extra fields in state, or several specialist agents. createReactAgent is like create-next-app, a fast start. You can switch to your own StateGraph later without changing your tools.