Agent Mini
A small AI agent you can read in an afternoon. It runs shell commands, edits files, searches the web and remembers things, using a small model on your own machine or any OpenAI-compatible API.
- Small: about 3,100 lines of Python, with only
httpx,clickandrichas dependencies. - Built for small models: tuned on 4B and 9B models with a task-eval harness. On qwen3.5:4b, the pass rate went from 88% to 97% with about a quarter fewer tool calls.
- Local-first: uses Ollama by default. OpenAI, LM Studio, vLLM and llama.cpp work too.
- Guard rails: a workspace sandbox by default, approval before commands and edits (
agent-mini initturns it on), and/undofor file changes. - Extras: persistent memory, saved sessions, and custom tools as plugins.
Quick start
pip install agent-mini
ollama pull qwen3.5:9b # or qwen3.5:4b on a smaller machine
agent-mini init # writes ~/.agent-mini/config.json
agent-mini doctor # checks the provider, model and setup
agent-mini chat
Or send one message from a script:
agent-mini chat -m "How many TODOs are in src/? Reply with just the number." --workspace .
Configuration
Settings live in ~/.agent-mini/config.json. Everything has a default, so only add what you change. config.example.json lists every setting.
{
"provider": "ollama",
"providers": { "ollama": { "model": "qwen3.5:9b" } },
"tools": { "confirm": ["shell", "write_file", "edit_file"] }
}
Leave out tools.confirm and the agent runs commands and edits files without asking (see Safety).
| Provider | Use it for |
|---|---|
ollama |
Ollama (the default) |
openai |
OpenAI. The key comes from apiKey, AGENT_MINI_API_KEY or OPENAI_API_KEY |
local |
Any OpenAI-compatible server, such as LM Studio, vLLM or llama.cpp. Set baseUrl |
To give the agent project instructions, such as build commands or code style, put an AGENTS.md file in the workspace.
Tools
| Tool | What it does |
|---|---|
shell |
Runs a command in the workspace |
read_file, write_file, edit_file |
Reads, creates and edits files |
list_files, search_files |
Finds files by glob and searches their contents |
web_search, web_fetch |
Searches DuckDuckGo and fetches pages |
remember, recall |
Saves facts across sessions and searches them |
To add your own tool, put a .py file that defines TOOL_DEF and handler in ~/.agent-mini/plugins/:
from datetime import datetime, timezone
TOOL_DEF = {
"type": "function",
"function": {
"name": "get_timestamp",
"description": "Get the current UTC timestamp.",
"parameters": {"type": "object", "properties": {}, "required": []},
},
}
async def handler(arguments: dict) -> str:
return datetime.now(timezone.utc).isoformat()
In the readonly sandbox, a plugin is loaded only if its TOOL_DEF has "x-readonly": true.
Chat commands
| Command | What it does |
|---|---|
/undo |
Reverts the agent's last file change |
/clear |
Starts a new conversation |
/model <name> |
Switches the model and saves it to the config |
/sessions, /load <id> |
Lists saved sessions and resumes one |
/help |
Shows all commands |
Ctrl+C stops the current turn. For multi-line input, wrap the text in """.
Safety
- Sandbox:
tools.sandboxLevelcontrols what the agent can reach.workspace(the default) keeps every path inside the workspace.readonlydoes the same and also removes the shell and file-writing tools.unrestrictedallows any path.
- Approval: tools listed in
tools.confirmask before they run. The list is empty unless you fill it;agent-mini initputsshell,write_fileandedit_filein it. Pass--yesto approve everything. - Guards: dangerous commands like
rm -rfandsudoare blocked. The shell doesn't get environment variables that look like secrets, andweb_fetchrefuses private addresses.
The guards reduce risk, but they aren't a security boundary. Approval is the real control.
Learn how it works
- docs/LEARN.md builds an agent in about 100 lines, then walks through what the real one adds. Start here.
- docs/how-it-works.html is an interactive tour of how one message flows through the agent.
- docs/TECHNICAL_IMPLEMENTATION.md covers the full design, including every small-model fix.
- evals/README.md describes the eval harness and has the latest results.
Development
git clone https://github.com/mohsinkaleem/agent-mini.git && cd agent-mini
uv sync --extra dev
uv run pytest
uv run ruff check src tests evals examples
To contribute, see CONTRIBUTING.md. Agent Mini is MIT licensed.
Metadata
Release files for agent-mini 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agent_mini-0.7.0.tar.gz | 132.4 kB | With provenance | Details for agent_mini-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agent_mini-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for agent_mini-0.7.0-py3-none-any.whl |
Total release size: 189.4 kB
Release files / agent_mini-0.7.0.tar.gz
| Download URL | agent_mini-0.7.0.tar.gz |
|---|---|
| Size | 132.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e209ac47c824cd337613f0e26cbc8ff0abc77cbac40e802c7f47b096ff2ffed
|
|
BLAKE2b-256 checksum How to use checksums |
01bbbb1a9fb80e60886b0ad02a76766d4d4bf6e29bdca0dce08a3b3d504bdb5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logRelease files / agent_mini-0.7.0-py3-none-any.whl
| Download URL | agent_mini-0.7.0-py3-none-any.whl |
|---|---|
| Size | 57.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b62233209fbd2927ec247ef377df85c3591b0d0ec7c2c297fc314bd1f9f9bb28
|
|
BLAKE2b-256 checksum How to use checksums |
48ddd979957e3dd3da978fabc0cbb6d72ebe0f0121df7434430059ae29b84052
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logSecurity for agent-mini 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for agent_mini-0.7.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.