# langchain-ai/react-agent architecture

> Architecture diagram of the GitHub repository langchain-ai/react-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/langchain-ai/react-agent
- Repository: https://github.com/langchain-ai/react-agent

## Overview

This is a LangGraph ReAct agent template. A user query enters the compiled graph as conversation state; the reasoning node loads and invokes the configured chat model with the system prompt. The model either produces a final answer or requests a tool. Tool routing dispatches search through Tavily, appends observations to state, and loops back to reasoning until completion. Configuration controls the model, prompt, and search limit. The sampled source shows this core path; persistence and additional tools are not present.

Main entry points: [`src/react_agent/graph.py`](https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/graph.py) (Reasoning Node), [`src/react_agent/tools.py`](https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/tools.py) (Search Tool), [`src/react_agent/state.py`](https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/state.py) (Conversation State), [`src/react_agent/context.py`](https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/context.py) (Agent Context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface_state["Interface and State"]
  node_conversation_state["Conversation State<br/>[state.py]"]
end

subgraph group_agent_graph["Agent Graph"]
  node_react_graph["ReAct Graph<br/>[graph.py]"]
  node_reasoning_node["Reasoning Node<br/>[graph.py]"]
  node_tool_router["Tool Router<br/>[graph.py]"]
  node_tool_executor["Tool Executor<br/>[graph.py]"]
  node_model_loader["Model Loader<br/>[utils.py]"]
end

subgraph group_configuration["Configuration"]
  node_agent_context["Agent Context<br/>[context.py]"]
  node_system_prompt["System Prompt<br/>[prompts.py]"]
end

subgraph group_tools_integrations["Tools and Integrations"]
  node_chat_model{{"Chat Model Provider"}}
  node_search_tool["Search Tool<br/>[tools.py]"]
  node_tavily{{"Tavily Search"}}
end

node_user(("User"))

node_user -->|"sends query"| node_react_graph
node_react_graph -->|"loads input"| node_conversation_state
node_react_graph -->|"starts reasoning"| node_reasoning_node
node_conversation_state -->|"provides messages"| node_reasoning_node
node_agent_context -->|"supplies settings"| node_reasoning_node
node_system_prompt -->|"provides template"| node_reasoning_node
node_reasoning_node -->|"loads model"| node_model_loader
node_model_loader -->|"initializes model"| node_chat_model
node_reasoning_node -->|"invokes model"| node_chat_model
node_chat_model -->|"returns response"| node_reasoning_node
node_reasoning_node -->|"appends response"| node_conversation_state
node_reasoning_node -->|"routes output"| node_tool_router
node_tool_router -->|"dispatches calls"| node_tool_executor
node_tool_executor -->|"invokes search"| node_search_tool
node_agent_context -->|"sets result limit"| node_search_tool
node_search_tool -.->|"queries web"| node_tavily
node_tavily -.->|"returns results"| node_search_tool
node_search_tool -->|"returns observation"| node_tool_executor
node_tool_executor -->|"appends observation"| node_conversation_state
node_tool_executor -->|"loops to reasoning"| node_reasoning_node
node_react_graph -->|"returns answer"| node_user

click node_conversation_state "https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/state.py"
click node_react_graph "https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/graph.py"
click node_reasoning_node "https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/graph.py"
click node_tool_router "https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/graph.py"
click node_tool_executor "https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/graph.py"
click node_agent_context "https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/context.py"
click node_system_prompt "https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/prompts.py"
click node_model_loader "https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/utils.py"
click node_search_tool "https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/tools.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_conversation_state,node_user toneBlue
class node_react_graph,node_reasoning_node,node_tool_router,node_tool_executor,node_model_loader toneAmber
class node_agent_context,node_system_prompt toneMint
class node_chat_model,node_search_tool,node_tavily toneRose
```

## Components

### Interface and State

- [Conversation State](https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/state.py): `src/react_agent/state.py`

### Agent Graph

- [ReAct Graph](https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/graph.py): `src/react_agent/graph.py`
- [Reasoning Node](https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/graph.py): `src/react_agent/graph.py`
- [Tool Router](https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/graph.py): `src/react_agent/graph.py`
- [Tool Executor](https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/graph.py): `src/react_agent/graph.py`
- [Model Loader](https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/utils.py): `src/react_agent/utils.py`

### Configuration

- [Agent Context](https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/context.py): `src/react_agent/context.py`
- [System Prompt](https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/prompts.py): `src/react_agent/prompts.py`

### Tools and Integrations

- **Chat Model Provider**
- [Search Tool](https://github.com/langchain-ai/react-agent/blob/main/src/react_agent/tools.py): `src/react_agent/tools.py`
- **Tavily Search**

### Other components

- **User**

## Connections

- User → ReAct Graph: sends query
- ReAct Graph → Conversation State: loads input
- ReAct Graph → Reasoning Node: starts reasoning
- Conversation State → Reasoning Node: provides messages
- Agent Context → Reasoning Node: supplies settings
- System Prompt → Reasoning Node: provides template
- Reasoning Node → Model Loader: loads model
- Model Loader → Chat Model Provider: initializes model
- Reasoning Node → Chat Model Provider: invokes model
- Chat Model Provider → Reasoning Node: returns response
- Reasoning Node → Conversation State: appends response
- Reasoning Node → Tool Router: routes output
- Tool Router → Tool Executor: dispatches calls
- Tool Executor → Search Tool: invokes search
- Agent Context → Search Tool: sets result limit
- Search Tool → Tavily Search: queries web
- Tavily Search → Search Tool: returns results
- Search Tool → Tool Executor: returns observation
- Tool Executor → Conversation State: appends observation
- Tool Executor → Reasoning Node: loops to reasoning
- ReAct Graph → User: returns answer
