explaingit

rulyone/simple-react-agent

Analysis updated 2026-06-24

103PythonAudience · developerComplexity · 2/5Setup · easy

TLDR

Hand-written ReAct agent in four short Python files that runs on a local Ollama Llama 3.2 3B model with a calculator and a DuckDuckGo search tool.

Mindmap

mindmap
  root((Simple-ReAct-Agent))
    Inputs
      User prompt
      Ollama model
      Tool list
    Outputs
      Thoughts
      Actions
      Final answer
    Use Cases
      Learn ReAct loop
      Local-only chat
      Tool dispatch demo
    Tech Stack
      Python
      Ollama
      Llama 3.2
      httpx
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Read four short Python files to learn the ReAct thought-action-observation loop without a framework.

USE CASE 2

Run a local agent with no API keys by pairing Ollama with Llama 3.2 3B.

USE CASE 3

Add a new tool by appending one entry to a Python dictionary in tools.py.

USE CASE 4

Use the REPL slash commands /clear and /history to inspect agent state between turns.

What is it built with?

PythonOllamaLlamahttpx

How does it compare?

rulyone/simple-react-agentclark-labs-inc/clark-browserluoyue789/sm4_detection
Stars103102104
LanguagePythonPythonPython
Setup difficultyeasymoderatehard
Complexity2/55/55/5
Audiencedeveloperdeveloperresearcher

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min

Needs Ollama installed plus a one-time pull of Llama 3.2 3B which is about 2 GB on disk.

In plain English

This project is a small, deliberately hand-written example of a ReAct agent that runs entirely on your own computer. A ReAct agent is a pattern where a language model alternates between thinking out loud, taking an action (like calling a tool), and reading the result, until it reaches a final answer. The author wrote it as a teaching exercise: four short Python files, no third-party agent framework hiding the loop. Every action is parsed out of the model's text reply and dispatched by hand. It runs on Ollama, which is a local program that hosts language models on your machine, paired with Llama 3.2 3B, a small open model that takes about 2 GB of disk space. There is no API key, no paid subscription, and no cloud calls for the model itself. You install Ollama, pull the model once, set up a Python virtual environment, install two dependencies (httpx and ddgs), and run a command-line REPL that lets you chat with the agent. The code is split across four files. llm.py is a thin wrapper that sends chat messages to Ollama and returns text. tools.py defines the two available tools: a calculator that safely evaluates math expressions, and a web search backed by DuckDuckGo, plus a dispatch helper. react.py contains the system prompt, the parser that pulls actions out of the model's reply, and the inner loop that runs one user turn through several thought-action-observation steps. repl.py is the outer multi-turn loop with simple slash commands like /clear and /history. The README explains the ideas the project is meant to teach: chat message roles (system, user, assistant), using stop sequences to make sure the model writes one action at a time, the fact that the language model is stateless so the full conversation history is resent every turn, the difference between the outer conversation loop and the inner reasoning loop, and how new tools can be added by putting one entry in a Python dictionary. There is a sample session showing the agent searching for the year of the last Chilean presidential election and then doing arithmetic on the answer. The README also covers tweaks like swapping in a smaller or larger Ollama model, raising the maximum number of reasoning steps, and common troubleshooting cases such as Ollama not being started or smaller models drifting away from the expected reply format.

Copy-paste prompts

Prompt 1
Run Simple-ReAct-Agent locally with Ollama and Llama 3.2 3B. Ask it to find the year of the last Chilean presidential election and double it.
Prompt 2
Add a third tool to tools.py that reads a local file and returns the first 200 characters. Show the dictionary edit.
Prompt 3
Explain why react.py uses stop sequences and how that prevents the model from writing two actions in one reply.
Prompt 4
Swap Llama 3.2 3B for Qwen 2.5 7B in this repo and adjust the system prompt so the reply format stays stable.
Prompt 5
Trace one full inner loop turn through llm.py, tools.py, and react.py for the prompt: what is 17 percent of 432?

Frequently asked questions

What is simple-react-agent?

Hand-written ReAct agent in four short Python files that runs on a local Ollama Llama 3.2 3B model with a calculator and a DuckDuckGo search tool.

What language is simple-react-agent written in?

Mainly Python. The stack also includes Python, Ollama, Llama.

How hard is simple-react-agent to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is simple-react-agent for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.