diff --git a/Makefile b/Makefile index e629494..4bfd878 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,9 @@ TEST_FILE ?= tests/unit_tests/ test: python -m pytest $(TEST_FILE) +integration_tests: + python -m pytest tests/integration_tests + test_watch: python -m ptw --snapshot-update --now . -- -vv tests/unit_tests diff --git a/README.md b/README.md index 6a5d6c2..cd666ab 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # LangGraph ReAct Agent Template [![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) -[![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) [![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) This 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. @@ -41,7 +40,7 @@ The primary [search tool](./src/react_agent/tools.py) [^1] used is [Tavily](http The defaults values for `model` are shown below: ```yaml -model: anthropic/claude-3-5-sonnet-20240620 +model: claude-sonnet-4-5-20250929 ``` Follow the instructions below to get set up, or pick one of the additional options. diff --git a/langgraph.json b/langgraph.json index 31264e4..43d1eb1 100644 --- a/langgraph.json +++ b/langgraph.json @@ -1,4 +1,5 @@ { + "$schema": "https://langgra.ph/schema.json", "dependencies": ["."], "graphs": { "agent": "./src/react_agent/graph.py:graph" diff --git a/pyproject.toml b/pyproject.toml index 6e66f7e..1ba46e0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ readme = "README.md" license = { text = "MIT" } requires-python = ">=3.11,<4.0" dependencies = [ - "langgraph>=0.6.0,<0.7.0", + "langgraph>=1.0.0", "langchain-openai>=0.1.22", "langchain-anthropic>=0.1.23", "langchain>=0.2.14", @@ -62,6 +62,7 @@ convention = "google" [dependency-groups] dev = [ - "langgraph-cli[inmem]>=0.1.71", + "anyio>=4.7.0", + "langgraph-cli[inmem]>=0.4.7", "pytest>=8.3.5", ] diff --git a/src/react_agent/context.py b/src/react_agent/context.py index 8ccfa75..238ccfd 100644 --- a/src/react_agent/context.py +++ b/src/react_agent/context.py @@ -22,7 +22,7 @@ class Context: ) model: Annotated[str, {"__template_metadata__": {"kind": "llm"}}] = field( - default="anthropic/claude-3-5-sonnet-20240620", + default="anthropic/claude-sonnet-4-5-20250929", metadata={ "description": "The name of the language model to use for the agent's main interactions. " "Should be in the form: provider/model-name." diff --git a/src/react_agent/graph.py b/src/react_agent/graph.py index 098f51b..9d2ca76 100644 --- a/src/react_agent/graph.py +++ b/src/react_agent/graph.py @@ -42,7 +42,7 @@ async def call_model( ) # Get the model's response - response = cast( + response = cast( # type: ignore[redundant-cast] AIMessage, await model.ainvoke( [{"role": "system", "content": system_message}, *state.messages] diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..ad84bd0 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,7 @@ +import pytest + + +@pytest.fixture(scope="session") +def anyio_backend(): + return "asyncio" + diff --git a/tests/integration_tests/test_graph.py b/tests/integration_tests/test_graph.py index 8c4ac57..a84adc3 100644 --- a/tests/integration_tests/test_graph.py +++ b/tests/integration_tests/test_graph.py @@ -1,12 +1,11 @@ import pytest -from langsmith import unit from react_agent import graph from react_agent.context import Context +pytestmark = pytest.mark.anyio + -@pytest.mark.asyncio -@unit async def test_react_agent_simple_passthrough() -> None: res = await graph.ainvoke( {"messages": [("user", "Who is the founder of LangChain?")]}, # type: ignore