Tool-calling agent for GLM-4.7-Flash-4bit via mlx-lm.server
Project description
Toolaide - an agentic coding assistant
A tool-calling agent powered by GLM-4.7-Flash-4bit (quantized via MLX) for local LLM development
๐ Overview
This project provides a command-line interface (CLI) tool that leverages the powerful GLM-4.7-Flash-4bit model to interact with your local workspace through tool calls. It's designed for:
- Local AI development - Run GLM-4.7 locally without cloud dependencies
- Tool-calling workflows - Execute file operations, searches, and more via natural language
- Interactive sessions - Chat with the model while it performs file operations
๐ Quick Start
Prerequisites
Before you begin, ensure you have:
- macOS (MLX is Apple Silicon optimized)
- Python 3.10+
- GPU memory - At least 8GB VRAM recommended, 16GB+ preferred
Step 1: Install Dependencies
# Create a virtual environment (recommended)
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install the package in editable mode
pip install -e .
Step 2: Start the MLX Server
Toolaide communicates with the MLX server which loads the model:
# Terminal 1 - Start the server with recommended settings for coding tasks
mlx_lm.server --model mlx-community/GLM-4.7-Flash-4bit --port 8080 --max-tokens 16384 --temp 0.7 --top-p 0.95
Note: The first run will download the model (~5.36GB). This may take 15-30 minutes depending on your internet speed.
Recommended settings:
--temp 0.7and--top-p 0.95are optimized for coding/software engineering tasks.
Step 3: Start Toolaide
# Terminal 2 - Start the tool-calling agent
toolaide --workspace .
You should see:
Workspace : /path/to/your/workspace
Server : http://localhost:8080
Tools : ['read_file', 'write_file', 'search_files', 'list_files']
> _
๐ก Basic Usage
Example 1: Reading a File
> read the contents of readme.md and summarize it in one sentence.
Example 2: Creating a New File
> create a Python function that calculates the fibonacci sequence, add it to utils.py
Example 3: Searching for Patterns
> find all instances of "TODO" or "FIXME" in the codebase and list the files.
Example 4: Interactive Session
> /help # View available commands
> /verbose on # Enable detailed output
> create a simple HTTP server in Python, and explain how it works.
๐ ๏ธ Available Tools
Toolaide provides 5 built-in tools for file and workspace operations:
| Tool | Description | Example Use Case |
|---|---|---|
read_file |
Read file contents | Review code, analyze existing files |
write_file |
Create or modify files | Write new code, make changes |
search_files |
Search for patterns in files | Find specific code, locate bugs |
list_files |
List files/directories | Navigate project structure |
list_tools |
List all available tools | Discover functionality |
Tip: The model automatically decides when to use which tool based on your request!
๐ Command Reference
Slash Commands
/verbose, /v - Toggle verbose mode (shows reasoning, tool results)
/verbose on|off - Set verbose mode explicitly
/quit, /exit, /q - Exit the session
/help - Show this help message
Command Line Arguments
toolaide [OPTIONS]
Options:
--workspace PATH Workspace directory (default: current directory)
--port PORT Server port (default: 8080)
-v, --verbose Enable verbose output
๐ฏ Best Practices
1. Always Read Before Writing
When modifying files, the model will automatically read the file first (per the system prompt rules).
2. Check Context Usage
Watch the token usage indicator in your output:
[tokens] prompt=15000 completion=200 [โโโโโโโโโโ] 75.5% context
โ ๏ธ Warning: At 90% context, consider starting a new session to avoid truncation.
3. Use Verbose Mode for Debugging
> /verbose on
This reveals:
- Model reasoning before tool calls
- Tool invocation details
- Result summaries
4. Handle Large Files
For files > 5MB, consider using list_files first to understand the structure, or search_files to locate specific content.
๐ Troubleshooting
"Resource limit exceeded" Error
RuntimeError: [metal::malloc] Resource limit (500000) exceeded2;
Solution: This means the GPU memory ran out. Try:
- Reduce
max_tokensin your requests (default is 16384) - Close other heavy applications
- Use a machine with more VRAM
Model Download Fails
If the MLX server can't download the model:
# Try downloading manually first
wget https://huggingface.co/mlx-community/GLM-4.7-Flash-4bit/resolve/main/model.safetensors
# Or use a mirror
Connection Refused
requests.exceptions.ConnectionError: [Errno 61] Connection refused
Solution: Ensure the MLX server is running:
ps aux | grep mlx_lm.server # Check if it's running
File Truncation Issues
If generated files are incomplete:
- Check the
max_tokenssetting (default 16384) - Request smaller, focused changes
- Use
list_filesto verify the output location
๐ Technical Details
Architecture
User Input
โ
Toolaide CLI (Python)
โ
MLX Server (C++)
โ
GLM-4.7-Flash-4bit Model (MLX)
Project Structure
.
โโโ toolaide/ # Main package
โ โโโ __init__.py
โ โโโ cli.py # CLI entry point
โ โโโ tools/ # Available tools
โ โ โโโ read_file.py
โ โ โโโ write_file.py
โ โ โโโ search_files.py
โ โ โโโ list_files.py
โ โ โโโ common.py
โโโ tests/ # Test suite
โโโ Makefile # Convenient targets
โโโ README.md # This file
Token Limits
- Context Window: 128,000 tokens (GLM-4.7 max)
- Default Completion: 16,384 tokens per response
- Recommended: Keep context below 75-80% to avoid performance issues
๐งช Testing
Run the test suite to verify everything works:
# Run all tests
make test
# Or with pytest
pytest -v
๐ฆ Building and Publishing
Building a Wheel Package
To create a distributable wheel package:
# Install dev dependencies (includes build and twine)
make install-dev
# Build the package
make build
This creates a dist/ directory with:
toolaide-0.2.0-py3-none-any.whl- Wheel packagetoolaide-0.2.0.tar.gz- Source distribution
Installing from Wheel
Share the wheel file with colleagues who can install it with:
pip install toolaide-0.2.0-py3-none-any.whl
Publishing to PyPI
-
Create a PyPI account
- Production: https://pypi.org/account/register/
- Test PyPI (recommended first): https://test.pypi.org/account/register/
-
Get an API token
- Go to Account Settings โ API tokens
- Create a token for uploading
-
Publish to Test PyPI first
make publish-testUsers can then install with:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ toolaide
-
Publish to production PyPI
make publishUsers can then install normally:
pip install toolaide
Note: Use
__token__as the username and your API token as the password when prompted by twine.
๐ Example Use Case: Code Refactoring
Here's a complete workflow example:
> I want to refactor the authentication module in api/auth.py.
> First, list the files in the api directory to see what's there.
> Then, read the current auth.py file.
> After that, create a new version with better error handling.
> Finally, show me a diff of what changed.
The model will:
- List files in
api/ - Read
api/auth.py - Write a refactored version to a temp file
- Compare and show you the differences
๐ Additional Resources
๐ค Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Submit a pull request
๐ License
MIT License - feel free to use this project for learning or personal projects.
๐ Acknowledgments
- Developed for the GLM-4.7-Flash-4bit model
- Built on MLX (Apple Silicon ML framework)
- Inspired by tool-calling agents like AutoGPT
Enjoy coding with your local AI! ๐
For issues or questions, please open an issue on GitHub.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file toolaide-0.2.0.tar.gz.
File metadata
- Download URL: toolaide-0.2.0.tar.gz
- Upload date:
- Size: 15.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d58a0b34a9b52563fe5d5c0dd4a1627909ed2cc871525cc1205ef6a00b6745b
|
|
| MD5 |
501d253174f9659bfae4e7079601f8f6
|
|
| BLAKE2b-256 |
cbe03c27740a9e40916ae882204007c3a808c11bbde7a7fc1b814717a5f9f441
|
File details
Details for the file toolaide-0.2.0-py3-none-any.whl.
File metadata
- Download URL: toolaide-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
866f3443a4ee3a6b99a410b615b63541d393e3d4ebae36b7cbae7bb6052ee586
|
|
| MD5 |
7d0b679d88cde0f1fd8611b9dd9df3a8
|
|
| BLAKE2b-256 |
df6e1d492ac334f7d7c93e82afadfb58f6489b581f5c0818c974cfb482da1e44
|