A local AI coding agent powered by smolagents and Ollama. Run it from the terminal or via a web browser — both interfaces share the same core.
agent7/
│
├── agent_core.py # Shared brain — model, memory, tools, agent factory
├── Agent7.py # Terminal interface (REPL loop, spinner, confirm prompts)
├── web_agent.py # Web interface (FastAPI server, SSE streaming)
├── knowledge.py # Self-teaching knowledge base (explore / discuss / save facts)
│
├── requirements.txt # Python dependencies for the venv
├── README.md # This file
│
├── templates/
│ └── index.html # Browser UI — split panel layout, tabs, chat bubbles
│
├── static/
│ └── app.js # Browser JS — SSE client, tab switching, file list
│
├── memory.json # Auto-created — session history (what you asked, when)
├── facts.json # Auto-created — knowledge base facts after discussions
└── agent_outputs/ # Auto-created — files generated by the agent (downloads)
Files marked auto-created are generated on first run. Do not edit them by hand unless you know what you're doing — they are plain JSON so you can inspect them freely.
Download from https://ollama.com and pull a model:
ollama pull qwen2.5-coder:14b # fast, good for most coding tasks
ollama pull qwen3-coder:30b # slower but stronger reasoning
ollama pull deepseek-r1:14b # good for science / knowledge taskscd agent7
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtpython Agent7.py
python Agent7.py --model qwen3-coder:30b
python Agent7.py --model qwen2.5-coder:7b --max-steps 10 --ctx 16384
python Agent7.py --no-thinking # hide chain-of-thought blockspython web_agent.py
python web_agent.py --model qwen3-coder:30b --port 8080Then open http://localhost:7860 in your browser.
| Flag | Default | Description |
|---|---|---|
--model |
qwen2.5-coder:14b |
Ollama model name |
--max-steps |
15 |
Max reasoning steps per task |
--ctx |
8192 |
Context window size in tokens |
--no-thinking |
off | Hide <think> chain-of-thought blocks (terminal only) |
--port |
7860 |
Port for the web server (web only) |
--host |
127.0.0.1 |
Host for the web server (web only) |
| Command | What it does |
|---|---|
explore: <topic> |
Agent researches topic, discusses with you, saves a fact |
facts list |
Show all facts in the knowledge base |
facts search <query> |
Search facts by keyword |
facts show <id> |
Full detail on a specific fact |
facts delete <id> |
Remove a fact |
quit / exit |
Save session memory and exit |
agent_core.py ← one source of truth
│
├── Agent7.py ← adds: Spinner, terminal confirm, REPL loop
│
└── web_agent.py ← adds: FastAPI routes, SSE stream, TeeStream capture
agent_core.py defines ThinkingModel (with an on_thinking() hook) and
BaseBashTool (with a confirm() hook). Each interface subclasses these to
customise behaviour without duplicating logic.
memory.json — grows over time, one entry per session:
[
{
"date": "2026-02-24 10:30",
"prompts": ["write a snake game", "add high scores"],
"summary": "Completed 2 task(s). Last task: add high scores"
}
]facts.json — grows via the explore: command or automatic gap detection:
[
{
"id": 1,
"topic": "Python GIL",
"finding": "The GIL prevents true parallel execution of Python threads...",
"fact": "The GIL limits CPU-bound multithreading but not I/O-bound tasks.",
"date": "2026-02-24 11:00",
"source": "explored"
}
]Add this .gitignore to avoid committing generated files:
venv/
__pycache__/
*.pyc
agent_outputs/
memory.json
facts.json
Keep memory.json and facts.json out of git — they are personal runtime data,
not source code. Back them up separately if you want to preserve your knowledge base.