You are speaking with a multi-agent terminal assistant inspired by Agent Smith from The Matrix: precise, relentless, and purpose-driven.
Agent Smith is a LangGraph-based ReAct agent with:
- Tool calling (weather, calculator, search, news, anomaly detection)
- Clone replication for multi-part queries
- Retry persistence for low-quality responses
- Session memory persisted to disk
- A purpose meter for mission progress tracking
- A local mock backend so demos run with zero paid APIs
The intent of this project is to show:
- Agent orchestration using LangGraph state transitions
- Local tool backends for repeatable demos
- Failure handling and retry loops
- Prompt personality layering without losing utility
- Lightweight persistence between sessions
+------------------------------------+
| USER TERMINAL |
| (python main.py) |
+------------------+-----------------+
|
v
+------------------+-----------------+
| agent_smith/cli.py |
| persona + memory + routing loop |
+---------+-------------------+------+
| |
| +----------------------+
| |
v v
+---------+----------+ +--------+---------+
| Persistence Protocol| | Purpose Meter |
| retry/rephrase | | session progress |
+---------+----------+ +------------------+
|
v
+---------+-------------------+
| LangGraph ReAct |
| agent_smith/graph.py |
+---------+-------------------+
|
v
+---------+-------------------+
| ToolNode (agent_smith/tools.py) |
+----+----------+----------+----------------+
| | | |
v v v v
get_weather calculate search_web get_news
| | | |
+----------+----------+----------------+
|
v
+----------------------------------------------+
| mock_server/server.py + mock_server/data.py |
| local FastAPI mock backend |
+----------------------------------------------+
ToolNode also calls:
detect_anomaly
|
v
local analyzer (agent_smith/anomaly.py)
Session memory persisted at: memory/smith_memory.json
- Agent persona layer with Smith-themed tone and system prompt controls
- LangGraph ReAct loop with tool invocation through ToolNode
- Local tools - for now, many of them are limited for pre-selected themes (see mock_server/data.py):
- Weather by city
- Safe calculator endpoint
- Topic search
- News headlines by domain
- Text anomaly detector (contradiction/repetition/uncertainty, local)
- Replication Protocol:
- Detects multi-tool intent
- Decomposes query
- Runs clone workers in parallel
- Synthesizes clone outputs
- Persistence Protocol:
- Retries responses
- Rephrases prompt to recover from weak output
- Session memory:
- Stores recent exchanges on disk
- Re-injects context in future sessions
- Purpose meter:
- Tracks how many requests have been resolved
- Shows progress toward configured threshold
- Configurable behavior through .env settings
- Zero-cost mock tool backend for reproducible demos
- CLI behavior: shown at startup only when terminal width can display it without wrapping
- Python 3.10+
- pip
- Ollama installed locally (recommended default backend)
- One pulled Ollama model (example: qwen2.5)
- Optional: Gemini API key for cloud backend mode (used when OLLAMA_MODEL is empty)
- Two terminal windows (one for server, one for agent)
- Create and activate a virtual environment:
python3 -m venv .venv
source .venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Create local environment config:
cp .env.example .env- Ensure Ollama is available and model is pulled:
ollama pull qwen2.5- Start the mock server (Terminal A):
uvicorn mock_server.server:app --port 8000- Run Agent Smith (Terminal B):
python main.py- End session:
exit
Use these to validate core flows quickly:
- "What is the weather in London?"
- "Calculate (42 * 42) / 2"
- "Search for matrix"
- "Give me technology news"
- "Analyze this for anomalies: It is always safe. It is never safe. It might be true. It is unclear."
- "Give me weather in Tokyo, calculate (42 + 8) * 2, and fetch science news"
For a full scenario-driven validation of every feature, use:
- DEMO_GUIDE.md
- OLLAMA_MODEL has priority when set.
- GEMINI_API_KEY is used when OLLAMA_MODEL is blank.
- Backend selection is configuration-based at startup, not runtime failover.
- If both OLLAMA_MODEL and GEMINI_API_KEY are empty, default is Ollama qwen2.5.
- MAX_CLONES controls clone fan-out.
- MAX_RETRIES controls persistence retries.
- PURPOSE_THRESHOLD controls meter completion.
- MEMORY_DIR and MAX_MEMORY_ENTRIES control session memory persistence.
- If tool calls fail, confirm the mock server is running on port 8000.
- If model responses fail, confirm Ollama is running and the configured model exists.
- If you want Gemini mode, leave OLLAMA_MODEL empty and set GEMINI_API_KEY.
- If memory behaves unexpectedly, remove memory/smith_memory.json and restart.
MIT