Companion code for the ruxu.dev blog post series on building a simple AI agent harness from scratch.
- Build a Basic AI Agent — A minimal conversational agent with a message loop, powered by a local model via Ollama.
- Build an AI Agent with Tools — Extends the agent with a tool registry so the LLM can read/write files, search the filesystem, run shell commands, and fetch web pages.
simple-agent/ # Part 1 — bare-bones agent loop
agent.py
agent-with-tools/ # Part 2 — agent with tool-calling support
agent.py
tools/
filesystem.py # read, write, search files
shell.py # run shell commands
web.py # fetch web pages
registry.py # tool registry & schemas
- Python 3.12+
- uv (recommended) or pip
uv syncYou can also change the current Ollama agent running gemma4 for any model of your choice.
uv run simple-agent/agent.pyuv run agent-with-tools/agent.pyType \exit to quit either agent.