{"id":15442319,"url":"https://github.com/langchain-ai/react-agent","last_synced_at":"2025-05-16T00:09:03.074Z","repository":{"id":256843193,"uuid":"845722720","full_name":"langchain-ai/react-agent","owner":"langchain-ai","description":"LangGraph template for a simple ReAct agent","archived":false,"fork":false,"pushed_at":"2025-02-26T23:09:46.000Z","size":1374,"stargazers_count":211,"open_issues_count":6,"forks_count":290,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-19T05:14:44.246Z","etag":null,"topics":["langgraph","langgraph-python","langgraph-template"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/langchain-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-21T19:57:32.000Z","updated_at":"2025-04-18T20:38:34.000Z","dependencies_parsed_at":"2025-01-15T17:33:58.522Z","dependency_job_id":"0e6bde5a-d863-4044-a61a-9a66392d690b","html_url":"https://github.com/langchain-ai/react-agent","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"4d198beb5a95cae4d55cfe89ed5291c1689f3b50"},"previous_names":["langchain-ai/react-agent"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-ai%2Freact-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-ai%2Freact-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-ai%2Freact-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/langchain-ai%2Freact-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/langchain-ai","download_url":"https://codeload.github.com/langchain-ai/react-agent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442855,"owners_count":22071878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["langgraph","langgraph-python","langgraph-template"],"created_at":"2024-10-01T19:26:36.230Z","updated_at":"2025-05-16T00:08:58.005Z","avatar_url":"https://github.com/langchain-ai.png","language":"Python","funding_links":[],"categories":["🦜 LangGraph 🕸️","Agent Categories"],"sub_categories":["Format Differences","\u003ca name=\"LangGraph\"\u003e\u003c/a\u003eLangGraph"],"readme":"# LangGraph ReAct Agent Template\n\n[![CI](https://github.com/langchain-ai/react-agent/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/langchain-ai/react-agent/actions/workflows/unit-tests.yml)\n[![Integration Tests](https://github.com/langchain-ai/react-agent/actions/workflows/integration-tests.yml/badge.svg)](https://github.com/langchain-ai/react-agent/actions/workflows/integration-tests.yml)\n[![Open in - LangGraph Studio](https://img.shields.io/badge/Open_in-LangGraph_Studio-00324d.svg?logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4NS4zMzMiIGhlaWdodD0iODUuMzMzIiB2ZXJzaW9uPSIxLjAiIHZpZXdCb3g9IjAgMCA2NCA2NCI+PHBhdGggZD0iTTEzIDcuOGMtNi4zIDMuMS03LjEgNi4zLTYuOCAyNS43LjQgMjQuNi4zIDI0LjUgMjUuOSAyNC41QzU3LjUgNTggNTggNTcuNSA1OCAzMi4zIDU4IDcuMyA1Ni43IDYgMzIgNmMtMTIuOCAwLTE2LjEuMy0xOSAxLjhtMzcuNiAxNi42YzIuOCAyLjggMy40IDQuMiAzLjQgNy42cy0uNiA0LjgtMy40IDcuNkw0Ny4yIDQzSDE2LjhsLTMuNC0zLjRjLTQuOC00LjgtNC44LTEwLjQgMC0xNS4ybDMuNC0zLjRoMzAuNHoiLz48cGF0aCBkPSJNMTguOSAyNS42Yy0xLjEgMS4zLTEgMS43LjQgMi41LjkuNiAxLjcgMS44IDEuNyAyLjcgMCAxIC43IDIuOCAxLjYgNC4xIDEuNCAxLjkgMS40IDIuNS4zIDMuMi0xIC42LS42LjkgMS40LjkgMS41IDAgMi43LS41IDIuNy0xIDAtLjYgMS4xLS44IDIuNi0uNGwyLjYuNy0xLjgtMi45Yy01LjktOS4zLTkuNC0xMi4zLTExLjUtOS44TTM5IDI2YzAgMS4xLS45IDIuNS0yIDMuMi0yLjQgMS41LTIuNiAzLjQtLjUgNC4yLjguMyAyIDEuNyAyLjUgMy4xLjYgMS41IDEuNCAyLjMgMiAyIDEuNS0uOSAxLjItMy41LS40LTMuNS0yLjEgMC0yLjgtMi44LS44LTMuMyAxLjYtLjQgMS42LS41IDAtLjYtMS4xLS4xLTEuNS0uNi0xLjItMS42LjctMS43IDMuMy0yLjEgMy41LS41LjEuNS4yIDEuNi4zIDIuMiAwIC43LjkgMS40IDEuOSAxLjYgMi4xLjQgMi4zLTIuMy4yLTMuMi0uOC0uMy0yLTEuNy0yLjUtMy4xLTEuMS0zLTMtMy4zLTMtLjUiLz48L3N2Zz4=)](https://langgraph-studio.vercel.app/templates/open?githubUrl=https://github.com/langchain-ai/react-agent)\n\nThis template showcases a [ReAct agent](https://arxiv.org/abs/2210.03629) implemented using [LangGraph](https://github.com/langchain-ai/langgraph), designed for [LangGraph Studio](https://github.com/langchain-ai/langgraph-studio). ReAct agents are uncomplicated, prototypical agents that can be flexibly extended to many tools.\n\n![Graph view in LangGraph studio UI](./static/studio_ui.png)\n\nThe core logic, defined in `src/react_agent/graph.py`, demonstrates a flexible ReAct agent that iteratively reasons about user queries and executes actions, showcasing the power of this approach for complex problem-solving tasks.\n\n## What it does\n\nThe ReAct agent:\n\n1. Takes a user **query** as input\n2. Reasons about the query and decides on an action\n3. Executes the chosen action using available tools\n4. Observes the result of the action\n5. Repeats steps 2-4 until it can provide a final answer\n\nBy default, it's set up with a basic set of tools, but can be easily extended with custom tools to suit various use cases.\n\n## Getting Started\n\nAssuming you have already [installed LangGraph Studio](https://github.com/langchain-ai/langgraph-studio?tab=readme-ov-file#download), to set up:\n\n1. Create a `.env` file.\n\n```bash\ncp .env.example .env\n```\n\n2. Define required API keys in your `.env` file.\n\nThe primary [search tool](./src/react_agent/tools.py) [^1] used is [Tavily](https://tavily.com/). Create an API key [here](https://app.tavily.com/sign-in).\n\n\u003c!--\nSetup instruction auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.\n--\u003e\n\n### Setup Model\n\nThe defaults values for `model` are shown below:\n\n```yaml\nmodel: anthropic/claude-3-5-sonnet-20240620\n```\n\nFollow the instructions below to get set up, or pick one of the additional options.\n\n#### Anthropic\n\nTo use Anthropic's chat models:\n\n1. Sign up for an [Anthropic API key](https://console.anthropic.com/) if you haven't already.\n2. Once you have your API key, add it to your `.env` file:\n\n```\nANTHROPIC_API_KEY=your-api-key\n```\n#### OpenAI\n\nTo use OpenAI's chat models:\n\n1. Sign up for an [OpenAI API key](https://platform.openai.com/signup).\n2. Once you have your API key, add it to your `.env` file:\n```\nOPENAI_API_KEY=your-api-key\n```\n\n\n\n\n\n\u003c!--\nEnd setup instructions\n--\u003e\n\n\n3. Customize whatever you'd like in the code.\n4. Open the folder LangGraph Studio!\n\n## How to customize\n\n1. **Add new tools**: Extend the agent's capabilities by adding new tools in [tools.py](./src/react_agent/tools.py). These can be any Python functions that perform specific tasks.\n2. **Select a different model**: We default to Anthropic's Claude 3 Sonnet. You can select a compatible chat model using `provider/model-name` via configuration. Example: `openai/gpt-4-turbo-preview`.\n3. **Customize the prompt**: We provide a default system prompt in [prompts.py](./src/react_agent/prompts.py). You can easily update this via configuration in the studio.\n\nYou can also quickly extend this template by:\n\n- Modifying the agent's reasoning process in [graph.py](./src/react_agent/graph.py).\n- Adjusting the ReAct loop or adding additional steps to the agent's decision-making process.\n\n## Development\n\nWhile iterating on your graph, you can edit past state and rerun your app from past states to debug specific nodes. Local changes will be automatically applied via hot reload. Try adding an interrupt before the agent calls tools, updating the default system message in `src/react_agent/configuration.py` to take on a persona, or adding additional nodes and edges!\n\nFollow up requests will be appended to the same thread. You can create an entirely new thread, clearing previous history, using the `+` button in the top right.\n\nYou can find the latest (under construction) docs on [LangGraph](https://github.com/langchain-ai/langgraph) here, including examples and other references. Using those guides can help you pick the right patterns to adapt here for your use case.\n\nLangGraph Studio also integrates with [LangSmith](https://smith.langchain.com/) for more in-depth tracing and collaboration with teammates.\n\n[^1]: https://python.langchain.com/docs/concepts/#tools\n\n\u003c!--\nConfiguration auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.\n{\n  \"config_schemas\": {\n    \"agent\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"model\": {\n          \"type\": \"string\",\n          \"default\": \"anthropic/claude-3-5-sonnet-20240620\",\n          \"description\": \"The name of the language model to use for the agent's main interactions. Should be in the form: provider/model-name.\",\n          \"environment\": [\n            {\n              \"value\": \"anthropic/claude-1.2\",\n              \"variables\": \"ANTHROPIC_API_KEY\"\n            },\n            {\n              \"value\": \"anthropic/claude-2.0\",\n              \"variables\": \"ANTHROPIC_API_KEY\"\n            },\n            {\n              \"value\": \"anthropic/claude-2.1\",\n              \"variables\": \"ANTHROPIC_API_KEY\"\n            },\n            {\n              \"value\": \"anthropic/claude-3-5-sonnet-20240620\",\n              \"variables\": \"ANTHROPIC_API_KEY\"\n            },\n            {\n              \"value\": \"anthropic/claude-3-haiku-20240307\",\n              \"variables\": \"ANTHROPIC_API_KEY\"\n            },\n            {\n              \"value\": \"anthropic/claude-3-opus-20240229\",\n              \"variables\": \"ANTHROPIC_API_KEY\"\n            },\n            {\n              \"value\": \"anthropic/claude-3-sonnet-20240229\",\n              \"variables\": \"ANTHROPIC_API_KEY\"\n            },\n            {\n              \"value\": \"anthropic/claude-instant-1.2\",\n              \"variables\": \"ANTHROPIC_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-3.5-turbo\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-3.5-turbo-0125\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-3.5-turbo-0301\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-3.5-turbo-0613\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-3.5-turbo-1106\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-3.5-turbo-16k\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-3.5-turbo-16k-0613\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-4\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-4-0125-preview\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-4-0314\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-4-0613\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-4-1106-preview\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-4-32k\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-4-32k-0314\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-4-32k-0613\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-4-turbo\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-4-turbo-preview\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-4-vision-preview\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-4o\",\n              \"variables\": \"OPENAI_API_KEY\"\n            },\n            {\n              \"value\": \"openai/gpt-4o-mini\",\n              \"variables\": \"OPENAI_API_KEY\"\n            }\n          ]\n        }\n      },\n      \"environment\": [\n        \"TAVILY_API_KEY\"\n      ]\n    }\n  }\n}\n--\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flangchain-ai%2Freact-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flangchain-ai%2Freact-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flangchain-ai%2Freact-agent/lists"}