A ReAct agent using LangGraph's prebuilt create_react_agent with math tools, running on Flyte.
- Creates a ReAct (Reason + Act) agent with OpenAI and LangGraph
- Defines simple math tools (
add,multiply) with@flyte.tracefor observability - The agent reasons about which tool to call, observes results, and loops until it has an answer
cd tutorials/starter-examples/langgraph-react-agent
uv venv .venv --python 3.11
source .venv/bin/activate
uv pip install -r requirements.txtTo run remotely, configure your Flyte cluster endpoint:
flyte create config \
--endpoint <your-endpoint> \
--auth-type headless \
--builder remote \
--domain development \
--project flytesnacksDon't have a cluster? Request access at flyte.org.
Remote:
uv run flyte run langgraph_react_agent.py agent --request "What is 12 * 7 plus 3?"Local:
uv run flyte run --local langgraph_react_agent.py agent --request "What is 12 * 7 plus 3?"Local with TUI:
The TUI gives you a live interactive terminal dashboard showing each task's status, logs, and outputs as the run progresses.
uv pip install textual
uv run flyte run --local --tui langgraph_react_agent.py agent --request "What is 12 * 7 plus 3?"Browse past local runs in TUI:
uv run flyte start tuiAfter a remote run completes, you can fetch the output with flyte.remote:
import flyte
from flyte.remote import Run
flyte.init_from_config()
runs = list(Run.listall(task_name="langgraph_env.agent", sort_by=("created_at", "desc"), limit=1))
run = Run.get(runs[0].name)
print(f"Phase: {run.phase}")
if run.phase.name == "SUCCEEDED":
print(run.outputs())OPENAI_API_KEYsecret configured on your Flyte cluster