A robust HTTP proxy server that fixes malformed tool calls from Qwen3-Coder LLM models before sending them to OpenCode or other downstream services.
Note: This proxy is primarily developed for OpenCode, but may be useful for other LLM environments requiring tool call format fixes.
Fixes Qwen3-Coder tool call issues:
- Consolidates fragmented tool calls across multiple SSE events
- Converts string parameters to proper types (arrays, booleans)
- Adds missing required parameters with sensible defaults
- Generates proper tool call IDs in OpenCode format
OpenCode successfully creating Conway's Game of Life using Qwen3-Coder through the proxy
- unsloth/Qwen3-Coder-30B-A3B-Instruct
- cpatonn/Qwen3-Coder-30B-A3B-Instruct-AWQ
- Python 3.8+
- A running Qwen3-Coder model server (typically on port 8080)
- OpenCode or compatible client
-
Clone the repository:
git clone https://github.com/yourusername/qwen3-call-patch-proxy.git cd qwen3-call-patch-proxy
-
Install dependencies:
pip install -r requirements.txt
-
Start the proxy:
python call_patch_proxy.py
-
Configure OpenCode to use the proxy: Point OpenCode to
http://localhost:7999
instead of your model server directly.
OpenCode ──→ Proxy (7999) ──→ Qwen3 Server (8080)
[Fixes tool calls]
To use this proxy with OpenCode, add the following provider configuration to your OpenCode settings:
{
"provider": {
"qwen3-coder-30b-a3b-instruct-vllm": {
"name": "Qwen 3 Coder 30B (vLLM)",
"npm": "@ai-sdk/openai-compatible",
"models": {
"cpatonn/Qwen3-Coder-30B-A3B-Instruct-AWQ": {}
},
"options": {
"baseURL": "http://127.0.0.1:7999/v1"
}
}
}
}
This configuration:
- Uses the proxy on port 7999 as the
baseURL
- Works with OpenAI-compatible API format
- Supports AWQ quantized models for efficient inference
- Health check:
GET http://localhost:7999/_health
- Reload config:
POST http://localhost:7999/_reload
For detailed information, see:
- Detailed Guide - Complete documentation with examples and configuration options
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes and add tests
- Commit:
git commit -m 'Add amazing feature'
- Push:
git push origin feature/amazing-feature
- Open a Pull Request
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.
- Built for the OpenCode ecosystem
- Designed to work with Qwen3-Coder models from Alibaba Cloud
- Inspired by the need for robust LLM tool call handling
Need help? Open an issue or check the discussions section!