A zero-latency terminal agent that keeps everything on-device by running large language models with Apple’s MLX framework. It is designed for developers who want a fast “copilot” without handing requests to remote services.
- MLX is Apple’s array and machine learning framework tuned for Apple silicon, providing memory-efficient primitives and vectorized kernels that keep inference on the GPU/ANE without context switches (Apple MLX).
- The
mlx-lmtooling ships optimized, quantized language models (e.g., 4-bit Phi-3, Mistral variants) plus a Python API forstream_generate, so you can decode tokens with minimal overhead straight from the CLI (mlx-examples).
pip install -e .
# Install MLX + MLX-LM wheels built for Apple silicon
pip install mlx-lm
# Optional: install the Hugging Face CLI for authenticated downloads
pip install "huggingface_hub[cli]"The project targets macOS 14+ on Apple Silicon. You need the MLX runtime from Apple’s mlx project for GPU/ANE acceleration.
# Generate a default config in ~/.config/mlx-agent/config.toml
mlx-agent init-config
# Chat interactively with default Qwen3 4-bit weights
mlx-agent chat
# One-shot question without entering the REPL
mlx-agent chat "How do I stream results from MLX inside Python?"
# Toggle ANSI colors if your terminal supports them
mlx-agent chat --color "Review main.py"If the models/ directory is empty, the CLI falls back to mlx-community/Qwen3-8B-MLX-4bit on Hugging Face. That repository requires accepting the license, so you must authenticate before the initial download.
-
Create an access token on https://huggingface.co/settings/tokens.
-
Log in from the terminal (the CLI installs an
hfexecutable):hf login
-
Pull the model into a local directory (you can choose any destination):
hf download mlx-community/Qwen3-8B-MLX-4bit \ --local-dir models/Qwen3-8B-MLX-4bit
-
Point the CLI at the downloaded weights:
mlx-agent chat --model models/Qwen3-8B-MLX-4bit "hello"
For other models, accept the license on Hugging Face first, then substitute the new repo ID in the commands above. The .gitignore already excludes models/ so large weights never end up in commits.
Key REPL shortcuts:
:help– show command list:clear– drop conversation history (keeps the system prompt):system <prompt>– swap the system persona on the fly:load <path>– bring a file’s contents into context (auto-truncates to keep fast decoding)!<command>– execute a shell command and feed stdout back into the model as fresh context
For single prompts you can also pass files up front:
mlx-agent chat --context src/main.py --context docs/plan.md "Review the diff above."The CLI merges CLI flags with TOML configuration. A generated config looks like:
model = "mlx-community/Qwen3-8B-MLX-4bit"
max_context_tokens = 8192
preload = true
[generation]
max_tokens = 1024
temperature = 0.2
top_p = 0.9
repetition_penalty = 1.05Adjust the model field to point at any MLX-compatible repository (local path or Hugging Face ID). Quantized weights finish loading in seconds and keep VRAM usage low enough for interactive workflows (mlx-examples docs).
- Warmup compilation – We issue a one-token warmup pass the first time you launch so MLX can JIT kernels and hit peak throughput immediately on subsequent prompts.
- Streaming render – Tokens arrive as soon as MLX emits them, making the CLI feel instantaneous compared with remote agents that wait on network round-trips.
- Context trimming – The conversation automatically prunes the oldest turns to stay under the configured token budget, avoiding runaway latency.
- Preload large files or recent command output via
:load/!<cmd>and drill into errors without leaving the terminal. - Persist transcripts to JSON with
--save-transcriptso you can diff prior sessions or feed them into unit tests. - Use different system prompts per project:
mlx-agent chat --system-prompt "You are a code reviewer".
- Leverage MLX prompt caching once upstream exposes a stable API.
- Add a
benchmarksubcommand that reports tokens/sec across candidate models. - Ship optional retrieval plugins that watch git status and automatically provide diff context.
python -m mlx_dev_agent.cli --helpRun linting, type checks, and tests:
ruff check mlx_dev_agent
pyright
python -m pytestEnable local pre-commit hooks once to run Ruff and Pyright before each commit:
pip install pre-commit
pre-commit installContributions are welcome! Please see CONTRIBUTING.md for guidelines, coding standards, and the expected test workflow. By contributing you agree to follow the Code of Conduct.
If you discover a potential security issue, follow the coordinated disclosure process described in SECURITY.md. Please avoid filing public GitHub issues for sensitive reports.
